javascript - 向 Angular 4 中的删除请求发送有效负载
问题描述
我的添加发布请求正常工作,但是当我尝试将相同的有效负载传递给删除请求时,我收到错误消息。api 是相同的值并接受相同的有效负载。只是一个不同的请求 POST 和 DELETE。
每个有效负载看起来像这样
{
jim : 1234
}
这是我的 add() / POST 请求(工作)
add() {
let jim = {
jim: this.htmlvalue
};
return this.myApiService.create({},
jim).subscribe(response => {
console.log('response', response);
this.reset();
},error => {
console.log('error', error);
}
);
}
这就是我正在尝试处理我的删除请求
delete(jim) {
let jim = {
jim: this.htmlvalue
};
return this.myApiService.remove({},
jim).subscribe(response => {
console.log('response', response);
this.reset();
},error => {
console.log('error', error);
});
}
错误信息是
Argument of type '{}' is not assignable to parameter of type 'string'.
这与删除请求中的 .remove({}, jim) 有关
解决方案
推荐阅读
- r - 如何使用 dplyr 计算条件?
- node.js - 嵌套js中的单元测试
- typescript - TypeScript 是否支持对象类型之间的真正 XOR 联合?
- python - 在 ExpressionWrapper 中结合 Django DateField 和 TimeField 给出 TypeError: expected string or bytes-like object
- javascript - 我想用firebase创建一个react native todo应用程序
- mysql - 使用 vb.net 和 mysql(在线)执行命令时遇到致命错误
- html - 无法使用 pypandoc 将图像从 docx 文件添加到 html 文件
- javascript - 异步函数中的 setState
- workflow - 如何从正在运行的 Snakemake 工作流程中可靠地获取状态信息?
- flutter - Flutter:如何启用通知声音