DELETE is not functioning as expected

A DELETE on

http://jsonplaceholder.typicode.com/posts/10000000000

will return with a “STATUS: 200 OK” which is wrong.

If I try a DELETE on:

https://my-json-server.typicode.com/typicode/demo/posts/100000000000

it returns with a “STATUS: 404 Not Found” which is correct.

I’m not sure how long the second URL will work. However, if you’re expecting the behavior in the video, you may be surprised. Keep in mind, the Angular function is working correctly. It’s just that for some reason the website mentioned in the video does not seem to respond the same way that it used to.

Course: Angular 4: Beginner to Pro
Section: Consuming HTTP Services
Video: 12- Handling Expected Errors

4 Likes

Thanks. I had the same issue

2 Likes

use

Fake restAPI instead of using jsonplaceholder
and change the ngOnInit() as below,

ngOnInit(): void {
this.service.getPosts()
.subscribe((response : any) =>{
this.posts = response.posts;
console.log(response)
},
);

}

1 Like