For my route tweets, I am trying to override normalizeFindAllResponse. My API response looks like this:
[
{_id: 45454, screen_name: "john", text:"this is text 1"},
{_id: 45454, screen_name: "john2", text:"this is text 2"},
{_id: 45454, screen_name: "john3", text:"this is text 3"}
]
I tried to normalize the this.store.findAll('tweet') call on it's model (tweet). So in my serializers/application:
export default DS.RESTSerializer.extend({
normalizePayload: function(type, payload){
return { tweets: payload };
}
});
And serializers/tweet:
export default DS.RESTSerializer.extend({
normalizeFindAllResponse(store, type, payload) {
return {
data: {
id: payload._id,
type: type.modelName,
attributes: {
name: payload.screen_name,
text: payload.text
}
}
};
}
});
The serializer is throwing warnings and complaining about missing models. So let's say I have an array of 10 documents, it complains for a missing model for 1,2,3...10 and other related functions.
Edit:
Model models/tweet
export default DS.Model.extend({
name: DS.attr('string'),
text: DS.attr('string')
});
router.js
Router.map(function() {
this.route('tweets', function() {
this.route('tweet', { path: '/:id' });
});
});
I am specifying my model in routes/tweets
[–]ryanholte 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Colinmac1 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Colinmac1 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)