传递一个 body 包含 json 项数组以在 angular 中删除
passing a body containing a json array of items for delete in angular
我有一个 REST API,如下所示,它使用 HTTP DELETE
方法。我必须在 Angular 中的那个 HTTP DELETE
方法中传递这个 body。请帮忙。我无法更改此 body
的结构
{
"transactions": [
{
"eventId": "21012200237172",
"productCode": "LC",
"id": "LC20110000090023"
}
]
}
您可以使用选项在 httpdelete 中传递正文
let apiUrl = 'yourUrl';
let transactions = [{
"eventId": "21012200237172",
"productCode": "LC",
"id": "LC20110000090023"
}];
const options = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
}),
body: {
transactions: transactions
},
};
this.httpClient
.delete(apiUrl, options)
.subscribe((s) => {
console.log(s);
},err => {
console.log(err);
});
我有一个 REST API,如下所示,它使用 HTTP DELETE
方法。我必须在 Angular 中的那个 HTTP DELETE
方法中传递这个 body。请帮忙。我无法更改此 body
{
"transactions": [
{
"eventId": "21012200237172",
"productCode": "LC",
"id": "LC20110000090023"
}
]
}
您可以使用选项在 httpdelete 中传递正文
let apiUrl = 'yourUrl';
let transactions = [{
"eventId": "21012200237172",
"productCode": "LC",
"id": "LC20110000090023"
}];
const options = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
}),
body: {
transactions: transactions
},
};
this.httpClient
.delete(apiUrl, options)
.subscribe((s) => {
console.log(s);
},err => {
console.log(err);
});