V. Déhaye
V. Déhaye

Reputation: 505

AngularJS http.get returns 404

I am trying to get a JSON from the openweathermap.org API using AngularJS, but my request returns an error code 404. Here is my code :

$scope.key = "XXXXXXXXXXXXX";

$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);});

I have tried requesting another url, and got the same problem with this one : http://www.omdbapi.com/?t=Sherlock%20Holmes&tomatoes=true&plot=full

Does someone have an idea about what is wrong here ?

Forgive me if that is obvious, I am brand new in AngularJS and I haven't found any solution on other topics.

Thank you in advance for your answers !

Upvotes: 5

Views: 2523

Answers (1)

pachonjcl
pachonjcl

Reputation: 741

The only error I see is that you are not setting http:// before the url

this is the response on my chrome

Request URL:http://api.openweathermap.org/data/2.5/weather?q=Rouen&APPID=XXXXXXXXXXXXX
Request Method:GET
Status Code:401 Unauthorized
Remote Address:192.241.169.168:80

of course a 401 Unauthorized for the APPID not being valid

Upvotes: 2

Related Questions