简体   繁体   English

Angular 5 httpClient-使用PUT jsonplaceholder 404

[英]Angular 5 httpClient - using PUT jsonplaceholder 404

I'm trying to test Angular 5 httpClient PUT with jsonplaceholder but it's giving me a 404. 我正在尝试使用jsonplaceholder测试Angular 5 httpClient PUT,但它给了我404。

Here is the code: 这是代码:

 putExample() {
    return this.httpClient.put<any>('http://jsonplaceholder.typicode.com/posts', { title: 'sometitle' });
  }

What I'm I doing wrong? 我做错了什么?

JSONPlaceholder does not have a PUT method for http://jsonplaceholder.typicode.com/posts/ hence the 404 Not Found. JSONPlaceholder没有用于http://jsonplaceholder.typicode.com/posts/的PUT方法,因此未找到404。

http://jsonplaceholder.typicode.com/ http://jsonplaceholder.typicode.com/

If you check the documentation again you'll see that for PUT requests will work with http://jsonplaceholder.typicode.com/posts/:id where id is a number. 如果再次查看文档,您会发现对于PUT请求将与http://jsonplaceholder.typicode.com/posts/:id一起使用 ,其中id是一个数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM