我试图在点击按钮时调用 post api 但我显示了这个错误:
Supplied parameters do not match any signature of call target
代码:
changeStatus(id) {
this.http.post('https://localhost:44300/api/apis/ChangeStatus/' + id)
.subscribe(
data => this._data = data.json(),
err => this.logError(err)
);
}
最佳答案
http.post
期望将正文发送到目标主机。
http.post(url, body, requestOptions)
所以如果你只是想要一个空的 body ,因为你没有额外的数据要发送,你可以这样做:
changeStatus(id) {
// mind the empty string here as a second parameter
this.http.post('https://localhost:44300/api/apis/ChangeStatus/' + id, "")
.subscribe(
data => this._data = data.json(),
err => this.logError(err)
);
}
关于typescript - Angular 2错误提供的参数与调用目标的任何签名都不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38324447/