5

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 !

2
  • where is the //? Commented Aug 22, 2016 at 1:36
  • This was the error, the lack of http ://, stupid ^^ thank you Commented Aug 22, 2016 at 2:09

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Well done that was my error, it works now, what an idiot ! Thank you very much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.