AngularJS $http error function never called

后端 未结 5 1031
陌清茗
陌清茗 2020-12-09 03:22

I have that simple code :

$http.get(\"/api/test\")
    .success(function (data, status, headers, config) {
        console.log(data);
        return data;
           


        
5条回答
  •  萌比男神i
    2020-12-09 04:09

    Maybe a little on late but... At the moment Angular $http request give you a premise so you can change it to:

    $http({
        method: "yourMethod",
        url: "yourUrl",
        data: {yourDataObj}
    }).then(function (res) {     //first function "success"
        console.log(res.data);
    }, function (err) {          //second function "error"
        console.log(err);
    });
    

提交回复
热议问题