yury-dymov / json-api-normalizer

Normalize JSON API data for redux applications
MIT License
576 stars 40 forks source link

data:null in relationships produces error TypeError: Cannot read property 'id' of null #4

Closed AndreyMirzoyan closed 7 years ago

AndreyMirzoyan commented 7 years ago

Normalization proudces error "TypeError: Cannot read property 'id' of null" in this example

... { "attributes": { "action": "ping", }, "id": "14", "relationships": { "ad_network": { "data": null } }, "type": "app_actions" } ...

To fix this error, please replace if (typeof object[key].data !== 'undefined') with if (typeof object[key].data !== 'undefined' && object[key].data !== null) {

yury-dymov commented 7 years ago

Hi @AndreyMirzoyan,

thank you for your feedback, please check the new version.

Kind regards, Yury.

AndreyMirzoyan commented 7 years ago

Thanks! It sloves my problem