So, I've got an Angular app that makes restful calls to the server. There is a service that wraps up the calls to the server. I currently have a method on the service that simply returns the promise from the $http service. I'd like to add some additional processing on that method call, but I'm not sure how to do it because of the asynchronous nature of the promise.
Currently in typescript:
class BoardService {
private $http;
constructor($rootScope: IRootScope, $http: ng.IHttpService) {
this.$http = $http;
}
fetchBoard(id: number) {
return this.$http.get("/api/board/" + id);
}
}
I'd like to get it to something like this:
fetchBoard2(id: number) {
this.$http.get("/api/board/" + id).success(function(data)
{
// Manipulate the data
});
// return manipulated data;
}
How would you do this?