According to the specification the server is allowed to send no data but when I try to save a resource with an id which results in a patch request the following error occurs while processing the response.
My code: this.resource.save().subscribe(() => { console.log('success'); });
Errorcore.js:6157 ERROR TypeError: Cannot read property 'data' of null at SafeSubscriber.Core.exec.subscribe.is_saving [as _next] (ngx-jsonapi.js:915)
Updating Resources: A server MUST return a 200 OK status code if an update is successful, the client’s current fields remain up to date, and the server responds only with top-level meta data. In this case the server MUST NOT include a representation of the updated resource(s).
In my opinion the problem relies in the following code snippet where there is a null check missing to make it work when no content is returned from the server.Before: if ('id' in success.data) { this.id = success.data.id; this.fill(/** @type {?} */ (success)); } else if (Array.isArray(success.data)) { console.warn('Server return a collection when we save()', success.data); }
After: if (!!success && 'id' in success.data) { this.id = success.data.id; this.fill(/** @type {?} */ (success)); } else if (!!success && Array.isArray(success.data)) { console.warn('Server return a collection when we save()', success.data); }
I would appreciate it very much if you could look into this issue and maybe provide a fix soon.
Best regards!
According to the specification the server is allowed to send no data but when I try to save a resource with an id which results in a patch request the following error occurs while processing the response.
My code:
this.resource.save().subscribe(() => { console.log('success'); });
Error
core.js:6157 ERROR TypeError: Cannot read property 'data' of null at SafeSubscriber.Core.exec.subscribe.is_saving [as _next] (ngx-jsonapi.js:915)
JSON:API - Latest Specification (v1.0)
In my opinion the problem relies in the following code snippet where there is a null check missing to make it work when no content is returned from the server. Before:
if ('id' in success.data) { this.id = success.data.id; this.fill(/** @type {?} */ (success)); } else if (Array.isArray(success.data)) { console.warn('Server return a collection when we save()', success.data); }
After:
if (!!success && 'id' in success.data) { this.id = success.data.id; this.fill(/** @type {?} */ (success)); } else if (!!success && Array.isArray(success.data)) { console.warn('Server return a collection when we save()', success.data); }
I would appreciate it very much if you could look into this issue and maybe provide a fix soon. Best regards!