My $http call looks like this and I would like to know the most flexible way to handle all of the parameters that are returned in the .success and .error?
this.$http({ url: "/api/x, method: "GET" })
.success((??) : void => {
})
.error((??) : void => {
})
The Angular documentation tells me the following are returned:
data – {string|Object} – The response body transformed with the transform functions.
status – {number} – HTTP status code of the response.
headers – {function([headerName])} – Header getter function.
config – {Object} – The configuration object that was used to generate the request.
statusText – {string} – HTTP status text of the response.
angular.d.ts shows me:
interface IHttpPromiseCallback<T> {
(data: T, status: number, headers: (headerName: string) => string, config: IRequestConfig): void;
}
interface IHttpPromiseCallbackArg<T> {
data?: T;
status?: number;
headers?: (headerName: string) => string;
config?: IRequestConfig;
statusText?: string;
}
But I am still confused. Has anyone used the two interfaces above to define the callbacks and how did they do it?
Ideally I would like to have something like this:
.success((data: any, status: number, headers: (headerName: string) => string, config: any) : void => {
But using the interfaces.
Can anyone tell me if I am on the right track and if I could use the interfaces rather than having to specify the :any :number etc after the parameters.