Foursquare API 405方法不允许?

时间:2017-05-09 01:57:32

标签: foursquare

这是我的代码:
此代码使用angularjs,但是当我提交它时出现消息错误“预检的响应有无效的HTTP状态代码405”

$scope.listLocation = []; 
$scope.getLocation = function() {

        var time = Date.now();
        return  $http({
            method: "POST", 
            url: 'https://api.foursquare.com/v2/venues/search?ll=11.5448729,104.8921668&client_id=.....&client_secret=......&v=1494294266811&limit=500&radius=500&intent=browse',
        }).then(function success(res) {
            $scope.listLocation = res.data.response.venues
        }, function error(res) {    

            return res;
        });
    }

1 个答案:

答案 0 :(得分:0)

如果您只是想检索数据,您似乎只需要将method"POST"更改为"GET"

    $scope.listLocation = []; 
    $scope.getLocation = function() {

    var time = Date.now();
    return  $http({
        method: "GET", 
        url: 'https://api.foursquare.com/v2/venues/search?ll=11.5448729,104.8921668&client_id=LP5KESHULNRR3BCNKBD3O1J1FNMWQ3RFRHN34SSLV0GPMQLV&client_secret=ZI5233EL5L5LVJZIVHWKWSCBUCX0HIQ3MUJAXIEYVWQGOJTR&v=1494294266811&limit=500&radius=500&intent=browse',
    }).then(function success(res) {
        $scope.listLocation = res.data.response.venues
    }, function error(res) {    

        return res;
    });
}

P.s。,client_secret查询参数看起来很敏感。