jsonapi-serializer
jsonapi-serializer copied to clipboard
can't keep specific attribute intact
I'm having a hard time understanding how to keep a specific attribute intact
I have a handful of attributes that are camelCased and then one that comes in sometimes that is __id__
It's not always there but when it is I need to pass it back to my client app as is
Here is what I have setup now but I can't get this to work
const TagSerializer = new JSONAPISerializer('tags', {
attributes: ['firstName', 'lastName', 'template',{
id: '__id__',
keyForAttribute: (attr) => {
return '__id__';
},
nullIfMissing: true
}],
keyForAttribute: 'camelCase',
});
The __id__ is not always there and doesn't get saved in my database