Angular 2错误提供的参数与呼叫目标的任何签名都不匹配 [英] Angular 2 Error Supplied parameters do not match any signature of call target
本文介绍了Angular 2错误提供的参数与呼叫目标的任何签名都不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在按钮单击时调用post api,但显示此错误:
I am trying to call post api on button click but I shows this error:
提供的参数与呼叫目标的任何签名都不匹配
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
expects a body to be sent to the target host.
http.post(url, body, requestOptions)
因此,如果您只想要一个空的正文,因为没有其他要发送的数据,则可以执行以下操作:
So if you just want an empty body, because you have no additional data to send, you could do this:
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)
);
}
这篇关于Angular 2错误提供的参数与呼叫目标的任何签名都不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文