0

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);
    });
}
ThomasReggi
  • 42,912
  • 63
  • 199
  • 343
  • Can you post a screenshot of the error you see in your browser's console? In your jsfiddle I only see a 405 error because of cross origin restrictions. – Loc Nguyen Mar 02 '14 at 20:58
  • This API does not implement CORS. It means that you should use JSONP. Fortunately they support it. However error handling is tricky for cross domain JSONP :( – dfsq Mar 02 '14 at 20:58
  • 1
    Looks similar to this: http://stackoverflow.com/questions/12111936/angularjs-performs-an-options-http-request-for-a-cross-origin-resource – MightySchmoePong Mar 02 '14 at 21:02

0 Answers0