X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c324b64f3b26e79b4640b6f0cf55671f1a261bca..3badd0539b3ba8e20db4c1243a02ce8dc6eb56a9:/src/services/common-service/common-resource-service.ts diff --git a/src/services/common-service/common-resource-service.ts b/src/services/common-service/common-resource-service.ts index f6810c0453..70c1df0e2b 100644 --- a/src/services/common-service/common-resource-service.ts +++ b/src/services/common-service/common-resource-service.ts @@ -62,7 +62,7 @@ export class CommonResourceService { } } - static defaultResponse(promise: AxiosPromise, actions: ApiActions): Promise { + static defaultResponse(promise: AxiosPromise, actions: ApiActions, mapKeys = true): Promise { const reqId = uuid(); actions.progressFn(reqId, true); return promise @@ -70,7 +70,9 @@ export class CommonResourceService { 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; @@ -89,7 +91,7 @@ export class CommonResourceService { this.actions = actions; } - create(data?: Partial | any) { + create(data?: Partial) { return CommonResourceService.defaultResponse( this.serverApi .post(this.resourceType, data && CommonResourceService.mapKeys(_.snakeCase)(data)),