Skip to content

Commit

Permalink
refactor(kitsu-core): use optional chaining in deserialise
Browse files Browse the repository at this point in the history
  • Loading branch information
wopian committed May 21, 2020
1 parent 94dc48a commit 43d5d4b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/kitsu-core/src/deserialise/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ export function deserialise (response) {
if (!response) return

// Collection of resources
if (response.data && Array.isArray(response.data)) response = deserialiseArray(response)
if (Array.isArray(response.data)) response = deserialiseArray(response)
// Single resource with included relationships
else if (response.included) response.data = linkRelationships(response.data, response.included)
else if (response.data && response.data.constructor === Object) response.data = linkRelationships(response.data)
else if (response.data?.constructor === Object) response.data = linkRelationships(response.data)

delete response.included

// Move attributes to the parent object
if (response.data && response.data.attributes) response.data = deattribute(response.data)
if (response.data?.attributes) response.data = deattribute(response.data)

return response
}

0 comments on commit 43d5d4b

Please sign in to comment.