I have been attempting to retrieve weather information from 'worldweatheronline' by making an $http call in an angular factory:
this.testApi = function(coords) {
var deferred = $q.defer();
$http.jsonp(API_ROOTS + '?key=9834687w634087623eg8932te&q=' + coords.latitude + ',' + coords.longitude + '&cc=yes&includeLocation=yes&format=json')
.then(function(response) {
deferred.resolve(response.current_condition);
console.log(response.current_condition);
}, function(error) {
deferred.reject(error);
}
);
return deferred.promise;
};
and controller:
$scope.updateLocalWeather = function() {
$geolocation.get().then(
function(position) {
$weather.testApi(position.coords).then(
function(weather) {
$scope.localWeather = weather;
$ionicSlideBoxDelegate.update();
}
);
}
);
};
However, I am encountering an error in the console:
Uncaught SyntaxError: Unexpected token :
Nevertheless, the response is successfully logged when I use console.log:
{ "data": { "current_condition": [ {"cloudcover": "0", "FeelsLikeC": "11", "FeelsLikeF": "51", "humidity": "42", "observation_time": "07:29 AM", "precipMM": "0.0", "pressure": "1029", "temp_C": "11", "temp_F":... (Text may be truncated)
I'm a bit puzzled as to what went wrong here. Any assistance would be highly appreciated.