【发布时间】:2017-12-12 00:26:32
【问题描述】:
试图通过openweathermap api调用数据 如果我通过'GET'方法调用它。有
405(不允许的方法)
var req = {
method: 'GET',
url: 'http://api.openweathermap.org/data/2.5/forecast/daily?APPID=' + ApiKey + '&q=London,us',
headers: {
'x-api-key': ApiKey
}
}
$http(req)
.then(function (data) {
console.log(data);
}, function (err) {
console.log(err);
});
【问题讨论】:
-
你使用的是哪个版本的角度?
-
试试 $http.get('api.openweathermap.org/data/2.5/forecast/daily?APPID=' + ApiKey + '&q=London,us');
-
试试
$http.get(URL,{header}).then(function(response){}).catch(function(err){}) -
@anand,它的 1.6+
-
@HimeshSuthar 仍然 401 错误