Body of Http.DELETE request in Angular2

前端 未结 12 1981
旧巷少年郎
旧巷少年郎 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条回答
  •  萌比男神i
    2020-12-02 09:04

    Below is an example for Angular 6

    deleteAccount(email) {
                const header: HttpHeaders = new HttpHeaders()
                    .append('Content-Type', 'application/json; charset=UTF-8')
                    .append('Authorization', 'Bearer ' + sessionStorage.getItem('accessToken'));
                const httpOptions = {
                    headers: header,
                    body: { Email: email }
                };
                return this.http.delete(AppSettings.API_ENDPOINT + '/api/Account/DeleteAccount', httpOptions);
            }
    

提交回复
热议问题