diff --git a/index.js b/index.js index 2699228..d78098f 100644 --- a/index.js +++ b/index.js @@ -59,6 +59,7 @@ const deserializeResource = (resource, included, transformFunc) => { Object.keys(relationships).forEach(key => { const relationship = relationships[key].data; + if (!relationship) return; if (Array.isArray(relationship)) { deserialized[transformFunc ? transformFunc(key) : key] = relationship.map(rel => { const includedResource = findIncluded(included, rel.type, rel.id); diff --git a/index.test.js b/index.test.js index b4679de..b90672d 100644 --- a/index.test.js +++ b/index.test.js @@ -39,6 +39,7 @@ const resp = { director: { data: { id: 1, type: "person" }, }, + studio: {} }, links: { self: "/movies/1",