mardi 2 mai 2017

TypeError: Cannot read property '0' of undefined when using RSVP.hash

I am trying to retrieve data for a route model using both ember-data and JSONAPIAdapter, it is working fine when i am only trying to fetch a single model, however, when i use RSVP.hash for multiple models, it breaks with 'TypeError: Cannot read property '0' of undefined'

Works

import Ember from 'ember';

export default Ember.Route.extend({
  // works
  model(params){
   return this.store.findRecord("campaign", params.campaign_id);
  }

});

Not working

import Ember from 'ember';

export default Ember.Route.extend({
  // does not work
  model(params) {
    return RSVP.hash({
      //'application': this.store.findRecord('app', params.application_id),
      campaign: this.store.findRecord("campaign", params.campaign_id)
    });
  }
});




Aucun commentaire:

Enregistrer un commentaire