【问题标题】:null with receipt data in angular $http带有角度 $http 收据数据的 null
【发布时间】:2016-08-11 10:32:31
【问题描述】:

这是我的代码:

 $scope.doLogin = function() {

    $http({
            method: "POST",
            url: "http://localhost:8000/api/v1/user/user_signin",
            data: { username: $scope.user.username, password: $scope.user.password },
            headers: { 'Content-Type': 'application/json' },
            responseType:'json'
        }).success(function (data) {
                console.log('data success');
                console.log(JSON.stringify(data)); 
        })
        .error(function(data, status, headers,config){
          console.log('data error');
        });

};

Consol 说:

数据成功

我做错了什么? P.S.:API 请求是正确的 - 我在邮递员中检查过。

【问题讨论】:

    标签: angularjs json http


    【解决方案1】:

    您将 responseType 设置为“json”,确保您的服务器端也发送与您的格式“json”兼容的响应。

    或者干脆删除响应类型检查是否有效

    【讨论】:

      猜你喜欢
      • 2019-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-02
      • 2016-04-29
      • 1970-01-01
      相关资源
      最近更新 更多