Skip to content

Instantly share code, notes, and snippets.

@mbranicky
Last active August 29, 2015 14:27
Show Gist options
  • Save mbranicky/875ce1741b286cca9b81 to your computer and use it in GitHub Desktop.
Save mbranicky/875ce1741b286cca9b81 to your computer and use it in GitHub Desktop.
Service (basic examples)
app.factory('forecast', ['$http', function($http) {
return $http.get('https://s3.amazonaws.com/codecademy-content/courses/ltp4/forecast-api/forecast.json')
.success(function(data) {
return data;
})
.error(function(err) {
return err;
});
}]);
app.factory('places', ['$http', function($http) {
return $http.jsonp('https://en.wikipedia.org/w/api.php?action=query&list=geosearch&gsradius=5000&gscoord=40.741934%7C-74.004897&gslimit=30&format=json&callback=JSON_CALLBACK').success(function(data) {
return data;
})
.error(function(err) {
return err;
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment