Skip to content

Instantly share code, notes, and snippets.

@malerba118
Last active June 14, 2017 05:22
Show Gist options
  • Save malerba118/f326b5da2243120e2e6cea75a1bb4967 to your computer and use it in GitHub Desktop.
Save malerba118/f326b5da2243120e2e6cea75a1bb4967 to your computer and use it in GitHub Desktop.
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