}
- // ToDo: add get method
-
update(uuid: string, data: Partial<CollectionResource>) {
if (uuid && data) {
const { properties } = data;
.defaultResponse(
this.serverApi
.put<CollectionResource>(this.resourceType + uuid, mappedData),
- this.actions
+ this.actions,
+ false
);
}
}
}
}
- 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;
order: order ? order : undefined
};
- const response = await CommonResourceService.customResponse(
+ const response = await CommonResourceService.defaultResponse(
this.serverApi
.get(this.resourceType + `${uuid}/contents`, {
params: CommonResourceService.mapKeys(_.camelCase)(params)
}),
- this.actions
+ this.actions,
+ false
);
const { items, ...res } = response;
const mappedItems = items.map((item: any) => {