vendredi 19 août 2016

Ember Error: Assertion Failed: `id` passed to `findRecord()` has to be non-empty string or number

Router.js

Router.map(function() {
  this.route('artists', function() {
    this.route('artist', {path: ':id'}, function() {
      this.route('songs');
    });
  });
});

routes/artists.js

export default Ember.Route.extend({
    model(){
        return this.store.findAll('artist');
    }
});

routes/artists/artist.js

export default Ember.Route.extend({
    model(params){
        console.log(params.id);  //printed a valid id (-KP_nH0EMk3zYqhiWJZ1)
        return this.store.findRecord(params.id);
    }
});

templates/artists.hbs


    <li class="list-group-item">   </li>


error

ember.debug.js:28535 Error while processing route: artists.artist.songs Assertion Failed: `id` passed to `findRecord()` has to be non-empty string or number Error: Assertion Failed: `id` passed to `findRecord()` has to be non-empty string or number
    at new Error (native)
    at Error.EmberError (http://localhost:4200/assets/vendor.js:26708:21)
    at assert (http://localhost:4200/assets/vendor.js:16548:13)
    at Object.assert (http://localhost:4200/assets/vendor.js:26472:34)
    at assert (http://localhost:4200/assets/vendor.js:68333:37)
    at Class.findRecord (http://localhost:4200/assets/vendor.js:76157:41)
    at Class.model (http://localhost:4200/assets/ember-basics.js:259:22)
    at Class.deserialize (http://localhost:4200/assets/vendor.js:37088:19)
    at Object.applyHook (http://localhost:4200/assets/vendor.js:63718:30)
    at Object.runSharedModelHook (http://localhost:4200/assets/vendor.js:61926:33)logError @ ember.debug.js:28535error @ ember.debug.js:28478triggerEvent @ ember.debug.js:28594trigger @ ember.debug.js:53473trigger @ ember.debug.js:53287(anonymous function) @ ember.debug.js:53107tryCatch @ ember.debug.js:53806invokeCallback @ ember.debug.js:53821publish @ ember.debug.js:53789publishRejection @ ember.debug.js:53724(anonymous function) @ ember.debug.js:32054invoke @ ember.debug.js:333flush @ ember.debug.js:397flush @ ember.debug.js:205end @ ember.debug.js:560run @ ember.debug.js:682run @ ember.debug.js:21139(anonymous function) @ firebase.js:134c @ firebase.js:396(anonymous function) @ firebase.js:387Ub @ firebase.js:283vc @ firebase.js:271wc @ firebase.js:270(anonymous function) @ firebase.js:454(anonymous function) @ firebase.js:427h.wd @ firebase.js:432af.wd @ firebase.js:335(anonymous function) @ firebase.js:333yd @ firebase.js:286La.onmessage @ firebase.js:285
ember.debug.js:32096 Error: Assertion Failed: `id` passed to `findRecord()` has to be non-empty string or number
    at new Error (native)
    at Error.EmberError (http://localhost:4200/assets/vendor.js:26708:21)
    at assert (http://localhost:4200/assets/vendor.js:16548:13)
    at Object.assert (http://localhost:4200/assets/vendor.js:26472:34)
    at assert (http://localhost:4200/assets/vendor.js:68333:37)
    at Class.findRecord (http://localhost:4200/assets/vendor.js:76157:41)
    at Class.model (http://localhost:4200/assets/ember-basics.js:259:22)
    at Class.deserialize (http://localhost:4200/assets/vendor.js:37088:19)
    at Object.applyHook (http://localhost:4200/assets/vendor.js:63718:30)
    at Object.runSharedModelHook (http://localhost:4200/assets/vendor.js:61926:33)

I am facing this error when navigatiing to "artists/{id}" and "artists/{id}/songs". I tried printing params.id in artists/artist route. i can see a valid id in console. can someone guess what could be the possible mistake




Aucun commentaire:

Enregistrer un commentaire