You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
foo is the only possible relationship (One related)
The service follows the JSON api specs, i.e. if no related foo, then there won't be relationships key on the Resource
Calling the GET service with include: ['foo']
Steps:
Load the resource with GET (doesn't matter with or without the related foo)
Update the resource, call removeRelationship('foo')
Save the resource with .save(), it will POST to the service
Load the same resource again with GET and check hasOneRelated
Issue:
TypeError: Cannot read property 'type' of null
at Ln.hasOneRelated ...
Analysis:
The foo was initialized as an empty Resource the first time, if there is no relationships key returned from the service
After the removal & save, the local Resource was updated and relationships.foo.data would become null
Since hasOneRelated checks ...relationships[resource].data).type, it will throw NullPointer exception
Angular Version:
8.1.3
ngx-jsonapi Version:
2.1.15
npm Version:
6.14.6
Typescript Version:
3.4.5
OS:
Windows 10
Given:
foo
is the only possible relationship (One related)The service follows the JSON api specs, i.e. if no related
foo
, then there won't berelationships
key on the ResourceCalling the GET service with
include: ['foo']
Steps:
foo
)removeRelationship('foo')
.save()
, it will POST to the servicehasOneRelated
Issue:
TypeError: Cannot read property 'type' of null
at Ln.hasOneRelated ...
Analysis:
foo
was initialized as an empty Resource the first time, if there is norelationships
key returned from the servicerelationships.foo.data
would becomenull
hasOneRelated
checks...relationships[resource].data).type
, it will throw NullPointer exceptionSuggestion:
add a condition in
hasOneRelated
, i.e.The text was updated successfully, but these errors were encountered: