angularjs - AngularJs http得到回应

标签 angularjs error-handling get

这是我的HTTP获取请求

 $http({
              method: 'GET',
              url: baseURL + '/couponManager/createCoupon?token=' + token + query1 + query2 + query3 + query4 + query5,
            }).then(function successCallback(response) {


                  if (response.status = 200)
                    {
                      $scope.showSuccessAlert = true;
                       $scope.successTextAlert = "Coupon successfully created!";
                    }

                  else if (response.status = 304)
                    { 
                      $scope.errorAlert = true;
                      $scope.errorTextAlert = "Something Went Wrong, Please try again!";
                     }

                }, function errorCallback(response) {

                     $scope.errorAlert = true;
                     $scope.errorTextAlert = "Can't reach server, please try later!";
              });

这是我得到的回应
{"success":"no","data":{},"error_code":"DW3","error_description":"Server Error"}

但是我收到的状态仍然是200,如何从该响应中检索“error_description”和“status”?

最佳答案

更改条件if (response.status == 200)else if (response.status == 304)

关于angularjs - AngularJs http得到回应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43464349/

相关文章:

python - Flask python断言错误: unimplemented method 'GET'

html - 在表单操作属性中包含 GET 变量

java - 处理服务器内的错误(例如 OutOfMemoryError)

angularjs - 在 ng-enter 之前类未绑定(bind)到 ui-view

javascript - 如何在angularjs Material 设计中显示标签标题居中对齐

angularjs - 在 angular.service 中使用 Angular 用户界面通知而不是 Controller ?

javascript - 如何在 MERN 堆栈中向用户显示错误

php - 测试 PDO 错误处理 : How to Force a Database Connection Error?

php - 如何使用$_GET?

angularjs - ng-model 不使用单选按钮更新