vendredi 27 janvier 2017

How to query server to retrieve single record / data in ember.js?

I'm trying to get my ember.js app to work.

I have the following code in app/routes/index.js:

import Ember from 'ember';

export default Ember.Route.extend({
    model() {
         // works - it calls the server
         Ember.$.getJSON('http://localhost:20000/Wallet');

         // does not work - server not hit
         this.get('store').findAll('Wallet');

         // this does not work either - server not hit
        this.store.queryRecord('/Wallet', {}).then(function(wallet) {
            //
        });

         // return some dummy data for now
         return 7111;
    }
});

and in my app/adapters/application.js:

import DS from 'ember-data';

export default DS.JSONAPIAdapter.extend({
    host: 'http://localhost:20000',
});

the "this.get('store').findAll('Wallet');" method just won't work. (The server does not get hit.)

What's wrong with my code?




Aucun commentaire:

Enregistrer un commentaire