I've got an angular services which should do all the http stuff required to let my controllers talk with my API.
export interface IDummyEntityApiService {
getAllDummies() : ng.IPromise<Array<Entities.IDummy>>;
}
class DummyEntityApiService implements IDummyEntityApiService {
private http: ng.IHttpService;
constructor($http : ng.IHttpService) {
this.http = $http;
}
getAllDummies() {
var url = "acme.com/api/dummies;
return this.http.get(url).then(result => {
return result.data;
}, error => {
// log error
});
}
}
Which I can then use like this:
dummyEntityApiService.getAllDummies.then(result => {
// fill results into list
}, error => {
fancyToast.create("Ooops, something went wrong: " + error);
});
My question is now - how would this work with POST
and DELETE
? I know $httpService
has methods like .post(url, data)
and .delete(url)
, and both of them return IHttpPromise<{}>
, but casting them up to a IPromise
doesn't really make sense since there is no data that needs to be resolved?