When developing services using TypeScript
for AngularJS
, should a model be defined for both the request and response?
For instance, in the scenario below where a service is calling a RESTFul endpoint:
module Application {
export module Services {
export class MyService {
public static $inject = ["$http"];
constructor(private $http: ng.IHttpService) {
}
getSomeData = (model: Models.RequestModel): ng.IPromise<Models.ResponseModel> => {
this.$http.post("url", model).then((response: ng.IHttpPromiseCallbackArg<Models.ResponseModel>) => {
return response.data;
});
}
}
}
}
Essentially, the RequestModel
is sent and the ResponseModel
is received in return.
Is this the correct use of syntax for this situation?