dimanche 26 juillet 2015

A value of a model is always undefined but the json api is not

In an Ember 1.13.3 application I have this simple model :

export default DS.Model.extend({
  name: DS.attr('string'),
  description: DS.attr('string'),
  link: DS.attr('string'),
  acquired_skills: DS.hasMany('users', { async: true, inverse: 'acquired_skills' } ),
  searched_skills: DS.hasMany('users', { async: true, inverse: 'searched_skills' } )
});

And I have this route :

import Ember from 'ember'

export default Ember.Route.extend({
  model: function() {
    console.log(this.store.find('skill', 1).get('name'));
    return this.store.find('skill');
  }
});

A request is sent at /skills/1 and this is the result :

{"skill":{"id":1,"name":"Ember","description":"JS Framework","acquired_skills":[1],"searched_skills":[1]}}

In the console, 'Ember' should be written but I have undefined.

Why I have no value for the name of the skill?

I have the same behaviour for all models and attributes.




Aucun commentaire:

Enregistrer un commentaire