}
}
- 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;
this.actions = actions;
}
- create(data?: Partial<T> | any) {
+ create(data?: Partial<T>) {
return CommonResourceService.defaultResponse(
this.serverApi
.post<T>(this.resourceType, data && CommonResourceService.mapKeys(_.snakeCase)(data)),