Hi,
My back end returns a published field for a post in the form yyyy-mm-dd. For the urls in Ember, I need to pass the year, month and day (with the slug as well) eg
/posts/2019/02/26/some-slug
I’ve tried extending the JSONAPISerializer class in order to adjust the payload from the server, but to no avail.
Any help much appreciated.
Many thanks
Sorted this. Added the three fields to the post model and extended normalizeResponse
app/serializers/post.js
export default ApplicationSerializer.extend({
normalizeResponse(store,primaryModelClass,payload,id,requestType) {
payload.data.forEach((post) => {
post.attributes.year = this.getYear(post.attributes.published);
post.attributes.month = this.getMonth(post.attributes.published);
post.attributes.day = this.getDay(post.attributes.published);
});
return this._super(...arguments);
},
})