200 Answer, but no JSON Data - problem with answers?

Using restangular and stub hub api. I can hit this API in firefox restclient and return the response body with all the JSON data.

But in my application I have 200, but there is no response body ... the length of the content even says something there

although the api says you just need a GET / URI endpoint and authorization: Bearer {token}

screen shot 2014-11-07 at 11 01 40 am

screen shot 2014-11-07 at 11 01 59 am

Here is my configuration configuration

'use strict'; angular.module('myapp') .config(['RestangularProvider', function(RestangularProvider){ RestangularProvider.setBaseUrl('https://api.stubhub.com/'); RestangularProvider.setDefaultHeaders({ Accept: 'application/json', Authorization: 'Bearer 198u2190832190831432742(notreallymytoken)' }); RestangularProvider.setDefaultHttpFields({ withCredentials: false }); }]); 

and here is my controller

 $scope.searchEvents = function(){ Restangular.one('search/catalog/events/v2?title="san francisco"').get().then(function(response){ $scope.searchResponse = response; }, function(response){ console.log("something went wrong"); }) } 

How can I start debugging? I want to continue using restangular, so I hope I can get around this somehow.

+3
source share
1 answer

I realized what the problem is, and maybe in your case too. The Content-Type for your answer would probably be similar to application/javascript and NOT application/json. This is why it does not get to Restangular, but through a browser or REST clients.

+1
source

Source: https://habr.com/ru/post/977925/


All Articles