From b085e16dcd68533d13f779688f8c94cd30a89ea9 Mon Sep 17 00:00:00 2001 From: Ricardo Neves Date: Sun, 17 Sep 2017 16:24:51 +0100 Subject: [PATCH] [Added] Validation for 204 No Content responses. --- src/services/json-api-datastore.service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/json-api-datastore.service.ts b/src/services/json-api-datastore.service.ts index 632a2b8c..b9ecffd5 100644 --- a/src/services/json-api-datastore.service.ts +++ b/src/services/json-api-datastore.service.ts @@ -90,8 +90,8 @@ export class JsonApiDatastore { } return httpCall .map((res: any) => this.extractRecordData(res, modelType, model)) - .map((res: any) => this.resetMetadataAttributes(res, attributesMetadata, modelType)) - .map((res: any) => this.updateRelationships(res, relationships)) + .map((res: any) => res ? this.resetMetadataAttributes(res, attributesMetadata, modelType) : res) + .map((res: any) => res ? this.updateRelationships(res, relationships) : res) .catch((res: any) => this.handleError(res)); } @@ -195,6 +195,9 @@ export class JsonApiDatastore { private extractRecordData(res: any, modelType: ModelType, model?: T): T { let body: any = res.json(); + if (!body) { + return null; + } if (model) { model.id = body.data.id; Object.assign(model, body.data.attributes);