ember.js - Handling promise rejection in ember-data with findQuery() -


i cannot seem ember-data reject failed (404's) when using findquery(..query..); find(..id..); works fine.

so in route:

app.postroute = ember.route.extend({    serialize: function(model, params) {     return { post_id: model.get('slug') };   },    model: function(params){     var query = {};     query.slugs = params.post_id;     return app.post.findquery(query).then(        function (data) {         return data.get('firstobject');       },        function (error) {         console.log('error');         throw 'boom!';       }     )   },    setupcontroller: function(controller, model){     this.controllerfor('post').set('content', model);   },    events: {     error: function (reason, transition) {      console.log('error!');     }   }  }); 

i have tried this:

return app.post.findquery(query).then( function (data) {   return data.get('firstobject'); }).then( null, function (error) {   console.log('error');   throw 'boom!'; }); 

no joy. can see request url returning 404, promises error never triggered. missing?

i don't know if it's typo, events hash in postroute should called events seam have defined singular event might problem why error hook inside hash not getting found , not invoked:

app.postroute = ember.route.extend({   ...   events: {     error: function (reason, transition) {       console.log('error!');     }   } }); 

hope helps.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -