Angular JS using $http() get a response, with status 200, but data is null

前端 未结 2 992
春和景丽
春和景丽 2021-01-20 16:46

I\'m using this angular code:

$http({
  method: \'get\',
  url: \'json/test.json\',
  responseType: \"json\"
}).success(function(data, status, headers, confi         


        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-20 17:31

    I don't know which version of AngularJS you are using, but assuming v1.6, then try this:

    $http.get("json/test.json").then(function(response) {
        console.log('success: ' + response.data);
    }).catch(function(response) {
        console.log('error: ' + response.data);
    });
    

提交回复
热议问题