Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 角度-如何从rest api接收嵌套错误消息对象_Javascript_Angularjs_Http Post - Fatal编程技术网

Javascript 角度-如何从rest api接收嵌套错误消息对象

Javascript 角度-如何从rest api接收嵌套错误消息对象,javascript,angularjs,http-post,Javascript,Angularjs,Http Post,似乎我当前的代码无法显示web api数据的返回 Angular$http.post return $http.post(`${calparkUrl}/api/request`, data, {calApiResponse: true}); 通过邮递员,我看到了这个错误 { "data": null, "hasErrors": true, "errorList": [ "T

似乎我当前的代码无法显示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."
     ]
  }
为了检索
hasrerrors
errorList
,我需要在$http.post中添加什么

更新

以下内容是否会显示响应或错误的console.log?我希望能够告诉调用者(调用此代码并期望返回的代码)数据是好是坏。。。等

 return $http.post(`${calibrusSparkUrl}/api/request`, data).
           then (function successCallback(function (response) {
               console.log(response);
           }).
            errorCallback(function (response) {
                console.log(response);
           });

RESTAPI返回该错误时的状态代码是什么?200-299范围内的状态代码转到成功处理程序,范围外的代码转到拒绝处理程序。请看。@georgeawg-我发布了另一个问题,我非常感谢您对我的答案的反馈,以及您可能给出的更好的答案