$http response header message
-
21-12-2019 - |
質問
is it possible in anulgarjs to fetch the response header message?
in a code similar to that
$http.get(url)
.success(){
something
}.error(status,"headers text message)"{
alert(status+" "+"headers text message or a method to get it";
}
in the alert i need to write somthing like that: 500 internal server error. In the console log i can see the error status and text message, what do i have to put in the error case? what is the best way to do that?
解決
try this
$http.get(url)
.then(function(response) {
var data = response.data;
var status = response.status;
alert(status);
});
他のヒント
Of course you can! On success (or error) you have a callback with this parameters
$http({
url: 'url',
method: 'GET'
}).success(function(data, status, headers, config){
});
Check the documentation http://docs.angularjs.org/api/ng/service/$http
所属していません StackOverflow