-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
First of all I want to say thank you for creating such neat package 🙇
Unfortunately I found a little bug using it. As it is stated in the title, If data.attributes contains type property (data.attributes.type) it is being overridden by type in data object (data.type)
As is:
const jsonApiNormalize = require('json-api-normalize');
const input = {
data: {
type: 'article', // <--
id: '1',
attributes: {
type: 'other type' // <--
title: 'JSON API paints my bikeshed!',
body: 'The shortest article. Ever.',
},
},
}
jsonApiNormalize(input).get(['type']);
// returns { type:"article" }
To be:
Should return { type:"other type" }
Not sure how this should be resolved, because there might be situation where data.type is also needed. Maybe some special char should be introduced like $ eg $id would be equal to data.id and $type to data.type
Metadata
Metadata
Assignees
Labels
No labels