angular(angular6/angular7/angular8) delete请求body的问题

angular中httpclient delete请求,不接受body,只需将其放在options对象中即可

在 angular6.x ,angular7.x, angular8.x及以上版本中修改如下:

const options = {
  headers: new HttpHeaders({
    'Content-Type': 'application/json',
  }),
  body:anyObject
};

this.httpClient
  .delete('http://localhost:8080/something', options)
  .subscribe((s) => {
    console.log(s);
  });

在Angular 2.x, 4.x and 5.x中,修改如下:

http.delete('/api/something', new RequestOptions({
   headers: headers,
   body: anyObject
}))

这样delete请求就可以携带body

你可能感兴趣的:(javascript,angular,angular6)