I'm retrieving posts from the store using store.find. When nothing could be found my server I'd like to transition to a different route but transitionToRoute() gives this error:
Error while processing route: posts undefined is not a function TypeError: undefined is not a function
When nothing could be found my server return HTTP 200 and the following JSON
{
"posts": [],
}
This is the route/posts.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function(params) {
var self = this
return this.store.find('posts', { permalink: params.permalink}).then(function(posts) {
// Error while processing route: base.posts undefined is not a function TypeError: undefined is not a function
if (posts.get('length') === 0) {
self.transitionToRoute('not-found')
}
return posts
);
},
afterModel: function(posts, transition) {
if (posts.get('length') === 0) {
// same error
this.transitionTo('not-found');
}
}
});
Aucun commentaire:
Enregistrer un commentaire