我有一个服务,我希望能够使用单个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数组。知道我做错了什么吗?
尝试一下不同的方法:
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json"
}),
body: JSON.stringify(leaguePics.map(lp => lp.id))
}