}
}
- static defaultResponse<R>(promise: AxiosPromise<R>, actions: ApiActions): Promise<R> {
+ static defaultResponse<R>(promise: AxiosPromise<R>, actions: ApiActions, mapKeys = true): Promise<R> {
const reqId = uuid();
actions.progressFn(reqId, true);
return promise
actions.progressFn(reqId, false);
return data;
})
- .then(CommonResourceService.mapResponseKeys)
+ .then((response: { data: any }) => {
+ return mapKeys ? CommonResourceService.mapResponseKeys(response) : response.data;
+ })
.catch(({ response }) => {
actions.progressFn(reqId, false);
const errors = CommonResourceService.mapResponseKeys(response) as Errors;
});
}
- static customResponse<R>(promise: AxiosPromise<R>, actions: ApiActions): Promise<R> {
- const reqId = uuid();
- actions.progressFn(reqId, true);
- return promise
- .then(data => {
- actions.progressFn(reqId, false);
- return data;
- })
- .then((response: { data: any }) => response.data);
- }
-
-
protected serverApi: AxiosInstance;
protected resourceType: string;
protected actions: ApiActions;