简体   繁体   中英

Yelp return 200 but error using $http

Yelp is returning status 200 with a JSON with results, but error callback is called. Maybe the JSON is malformed? I don't think so. But I cannot understand what is happening.

This is the code (angularjs):

$http.jsonp('https://api.yelp.com/v2/search?term=food&location=San+Francisco', {
    params: params, //All oauth params are correctly filled
    headers: {
        'Content-Type': 'application/json'
    }
}).success(function(data){
    deferred.resolve(data);
})
.error(function(error){
    deferred.reject(error);
});

Thanks!

Solved!

callback parameter was missing in params. In my example, I have added callback: 'angular.callbacks._' + index

where index starts at 0 and must be incremented each time I make a call

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM