jeudi 31 août 2017

EmberJS queryRecord do not returns all data

Hi starting to learn emberJS, and periodicaly become a little bit confused. maybe someone can suggest any examples more advanced than in official documantation?

Back to the current problem, I have:

Adapter

export default DS.JSONAPIAdapter.extend({
  queryRecord(store, type, query) {
    return Ember.$.getJSON("http://localhost:3000/user");
  }
});

Model

export default DS.Model.extend({
  username: DS.attr(),
  fullname: DS.attr(),
  email: DS.attr()
});

then in router:

  model() {
    this.get('store')
      .queryRecord('user', {})
      .then(function (res) {
        let username = res.get('username');
        console.log(`Currently logged in as ${username}`);
      });
  },

Why I get user name undefined, as well as all other properties exept id. Depite in browser response i see:

{
 "data":{"type":"user",
        "id":"u2",
        "username":"user2",
        "password":"pass2",
        "fullname":"Test User Two",
       "email":"user.two@test.com"}
}

What I missed?




Aucun commentaire:

Enregistrer un commentaire