Yelp使用$ http返回200但错误

时间:2016-06-02 20:25:27

标签: angularjs http oauth yelp

Yelp返回状态200,带有带结果的JSON,但调用了错误回调。也许JSON格式不正确?我不这么认为。但我无法理解发生了什么。

这是代码(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);
});

谢谢!

1 个答案:

答案 0 :(得分:0)

解决!

参数中缺少

回调参数。在我的例子中,我添加了回调:' angular.callbacks ._' + index

其中index从0开始,每次拨打电话时都必须递增