Last active
June 14, 2017 05:22
-
-
Save malerba118/f326b5da2243120e2e6cea75a1bb4967 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.service("NoteService", function($http, $q) { | |
this.getNotes = function() { | |
return $http.get("https://jsonplaceholder.typicode.com/posts") | |
.then( | |
//success | |
function(response) { | |
return response.data; | |
}, | |
//error | |
function(error) { | |
return $q.reject("Failed to get notes"); | |
} | |
); | |
}; | |
this.getNote = function(id) { | |
return $http.get("https://jsonplaceholder.typicode.com/posts/" + id) | |
.then( | |
//success | |
function(response) { | |
return response.data; | |
}, | |
//error | |
function(error) { | |
return $q.reject("Failed to get note"); | |
} | |
); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment