我试图在单击按钮时调用 post api,但显示此错误:
提供的参数与调用目标的任何签名都不匹配
Code:
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)
因此,如果您只想要一个空正文,因为您没有其他数据要发送,您可以这样做:
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)
);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)