我有 2 个 POST 正在通过 Promise 运行,但无论哪一个在内部,它们都会捕获而不执行内部 POST。
我有以下代码:
this.http.post(medurl, datamed)
.toPromise()
.then(response => {
console.log('Post Success!');
console.log('Reponse: ' + response);
if (response != 0){
this.http.post(scripturl, datascript)
.toPromise()
.then(response => {
console.log('Post Success!');
console.log('Reponse: ' + response);
})
.catch(error => {
console.log('Post Error!');
console.log('Reponse: ' + typeof(error));
});
}
})
.catch(error => {
console.log('Post Error!');
console.log('Reponse: ' + typeof(error));
});
我不确定问题是什么,因为我已经对 POST 字段进行了两次三重检查,它们在不同的上下文中工作得很好,而且响应是 200。
我不确定要在此处添加哪些其他详细信息,但如果您需要更多信息,请告诉我。
我遇到了类似的问题,我收到了 200 状态响应,但仍然会抛出错误。我必须设置responseType
属性上的options
的参数HttpClient
的帖子方法。
this.http.post(medurl, datamed, { responseType: 'text' })
.toPromise()
.then(response => {
....
})
.catch(error => {
console.log('Post Error!');
console.log('Reponse: ' + typeof(error));
});
https://angular.io/guide/http#requesting-non-json-data https://angular.io/guide/http#requesting-non-json-data
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)