mardi 25 avril 2017

Ember model finding records

I'm having trouble getting Ember's queryRecord to work properly. I'm trying to grab a site config from the server.

//app/routes/application.js

model: function(){
    var self = this;

   var config = this.get('store').queryRecord('config',{}).then(function(config) {
    console.log(config.get('appname'));
  });
}

//app/adapters/config.js

import DS from "ember-data";
import ENV from './../config/environment';

export default DS.Adapter.extend({
  queryRecord(modelName, query) {
      return Ember.$.getJSON( ENV.APP.apiFull + 'config' );
  }
});

//JSON returning from server AJAX call

{"config":{"id":1,"environment": "development", "appname":"Sample App Name"}}

The console.log statement in //app/routes/application is returning undefined. This all seems to match up with the Ember documentation for version 2.9. What am I doing incorrectly?




Aucun commentaire:

Enregistrer un commentaire