Body of Http.DELETE request in Angular2

前端 未结 12 1972
旧巷少年郎
旧巷少年郎 2020-12-02 08:23

I\'m trying to talk to a somewhat RESTful API from an Angular 2 frontend.

To remove some item from a collection, I need to send some other data in addition to the re

12条回答
  •  温柔的废话
    2020-12-02 09:29

    If you use Angular 6 we can put body in http.request method.

    Reference from github

    You can try this, for me it works.

    import { HttpClient } from '@angular/common/http';
    
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.scss'],
    })
    export class AppComponent {
    
      constructor(
        private http: HttpClient
      ) {
        http.request('delete', url, {body: body}).subscribe();
      }
    }
    

提交回复
热议问题