You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to build links for a resource using the request object from express, but the links option in schemas does not get passed options like topLevelLinks does.
Seems like any function in a schema should get passed both data and options, like this:
constSerializer=newJSONAPISerializer();Serializer.register('message',{whitelist: ['body','created_at'],// currently only accepts an options argument :(topLevelLinks: function(data,options){letlastRecordId=data[data.length-1].id;return{next: `${options.req.get('host')}${options.req.baseUrl}/messages?older_than=${lastRecordId}`}},// currently only accepts a data argument :(links: function(data,options){return{self: `${options.req.get('host')}${options.req.baseUrl}/messages`}}});letmessages=serializer.serialize('message',results,{req});
Perhaps even the entire schema could be a function
I want to build links for a resource using the request object from express, but the
links
option in schemas does not get passedoptions
liketopLevelLinks
does.Seems like any function in a schema should get passed both
data
andoptions
, like this:Perhaps even the entire schema could be a function
The text was updated successfully, but these errors were encountered: