Reputation: 11649
I am trying to send an http get request to a host using this code:
$scope.completeResult=
$resource("api.openweathermap.org/data/2.5/forecast/daily", { callback: "JSON_CALLBACK" }, { get: { method: "JSONP" }});
$scope.finalResult=$scope.completeResult.get({ q: "London", APPID: 'myID' , cnt: 2 });
console.log( $scope.finalResult);
But I get a 404 error. When I checked the Inspect -> Network
it turns out that it sends the request to: http://127.0.0.1:27469/views/api.openweathermap.org/data/2.5/forecast/daily?APPID=myID&callback=angular.callbacks._0&cnt=2&q=London
As you can see, it sends the get request to my localhost rather than real host
http://127.0.0.1:27469/views/
How can i fix it?
Upvotes: 0
Views: 61
Reputation: 30737
Have you tried http://api.openweathermap.org/data/2.5/forecast/daily
- add the http:// part to your resource url. It looks like your current url is relative to your site.
so this:
$resource("api.openweathermap.org/data/2.5/forecast/daily", { callback: "JSON_CALLBACK" }, { get: { method: "JSONP" }});
becomes this
$resource("http://api.openweathermap.org/data/2.5/forecast/daily", { callback: "JSON_CALLBACK" }, { get: { method: "JSONP" }});
Upvotes: 3