我有一项服务,我希望能够通过一个http.delete发送一组ID。到目前为止,我有以下内容:
`
removeLeaguePictures(leaguePics: LeaguePicture[]) {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json"
}),
body: {
idss: JSON.stringify(leaguePics.map(lp => lp.id))
}
};
return combineLatest([
this.leaguePictures$,
this.http.delete<boolean>(this.galleryUrl, options)
]).pipe(...)
`
但这似乎没有发送列表,或者我只是不知道如何在后端Asp.Net核心终结点上检索它
在后端服务器中,我将执行以下操作:
`
[HttpDelete]
public async Task<ActionResult<bool>> Delete([FromBody] long[] ids)
{...}
`
但是我无法获取要填充的ids数组。有什么想法我做错了吗?
答案 0 :(得分:1)
尝试一下不同:
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json"
}),
body: JSON.stringify(leaguePics.map(lp => lp.id))
}