Wednesday, July 3, 2019

ajax - Why doesn't angular $http data return error object

I'm trying to return the twitter API error object in this jsfiddle.



Here's the error:




{
errors: [
{
message: "Bad Authentication data",
code: 215
}
]
}



Here's the code:



var myApp = angular.module('myApp', []);

function MyCtrl($scope, $http) {
$http({
method: "GET",
url: "https://api.twitter.com/1.1/statuses/user_timeline.json",
responseType: "json",
params: {

screen_name: "StackCareers"
}
}).
success(function (data, status, headers, config) {
$scope.data = JSON.stringify(data);
}).
error(function (data, status, headers, config) {
$scope.data = JSON.stringify(data);
});
}

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...