Znowman
Znowman

Reputation: 395

angularjs print datafrom API

Trying to print data from an API call to one of my views:

{{forecast.list.rain['3h']}}

Making the API call successfully and the data logs in the console.

var urlForecast = "http://api.openweathermap.org/data/2.5/forecast?id=" + 
                  $routeParams.cityId + 
                  "&appid=d436c04d23a5a44329eb8255190a84be&callback=JSON_CALLBACK";

var forecastCall = urlForecast;
var promise2 = $http.jsonp(forecastCall);

promise2.success(function(forecast) {
    $scope.forecast = forecast;
    console.log($scope.forecast);
});

Not printing anything, cant see whats wrong.

Upvotes: 0

Views: 37

Answers (1)

Deividas
Deividas

Reputation: 6507

Try using .then instead of .success, because if there's an error, .success method is not firing.

Upvotes: 1

Related Questions