似乎我现有的这个代码无法向我显示web api数据的返回
Angular $ http.post
return $http.post(`${calparkUrl}/api/request`,
data,
{calApiResponse: true});
使用邮递员,我看到此错误
{
"data": null,
"hasErrors": true,
"errorList": [
"This Order cannot be submitted as entered. A combination of this information is already in use."
]
}
我需要添加什么来添加到我的$ http.post才能检索hasErrors
和errorList
??
更新
以下是否会显示console.log以获取响应或错误?我希望能够告诉调用者(调用此代码并期望返回的代码)数据是好还是坏......等等
return $http.post(`${calibrusSparkUrl}/api/request`, data).
then (function successCallback(function (response) {
console.log(response);
}).
errorCallback(function (response) {
console.log(response);
});
答案 0 :(得分:0)
试试这个
function sendData($scope) {
$http({
url: 'request-url',
method: "POST",
data: { 'message' : message }
})
.then(function(response) {
// success
},
function(response) { // optional
// failed
});
}