mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-05-11 08:11:38 +00:00
Moved api call to a service
This commit is contained in:
17
frontend/app/js/tournaments-service.js
Normal file
17
frontend/app/js/tournaments-service.js
Normal file
@@ -0,0 +1,17 @@
|
||||
app.factory('tournamentsService', function($http){
|
||||
|
||||
|
||||
return {
|
||||
getAllTournaments: function() {
|
||||
//since $http.get returns a promise,
|
||||
//and promise.then() also returns a promise
|
||||
//that resolves to whatever value is returned in it's
|
||||
//callback argument, we can return that.
|
||||
return $http.get('/api/tournaments/').then(function(result) {
|
||||
return result.data;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user