【发布时间】:2016-08-22 01:20:34
【问题描述】:
我正在尝试使用 AngularJS 从 openweathermap.org API 获取 JSON,但我的请求返回错误代码 404。这是我的代码:
$scope.key = "XXXXXXXXXXXX";$scope.search = "Rouen";
$scope.url= "api.openweathermap.org/data/2.5/weather?q=" + $scope.search + "&APPID=" + $scope.key;
$scope.fetch = function(){
$http.get($scope.url)
.then(function(response){
$scope.res = response.data;
$scope.status= response.status;},
function errorCallback(response) {
alert(response.status);});
我尝试过请求另一个网址,但遇到了同样的问题:http://www.omdbapi.com/?t=Sherlock%20Holmes&tomatoes=true&plot=full
有人知道这里出了什么问题吗?
如果这很明显,请原谅我,我是 AngularJS 的新手,我还没有找到其他主题的任何解决方案。
提前感谢您的回答!
【问题讨论】:
-
//在哪里? -
这是错误,缺少http://,笨^^谢谢
标签: javascript angularjs http-status-code-404