mardi 13 septembre 2016

Adding Records to Ember Data Store after Ajax Success

I am building a Ember Application where I fetch a feed of Debate objects from an API end point in a route, via the following ajax call:

import Ember from 'ember';
export default Ember.Route.extend({
  model: function() {

    $.getJSON("http://localhost:3000/api/v2/debate_feed").then(debates => {
      store.push(debates);
    });

  }
});

Upon receiving the Debate objects I need to save them to the data store, the problem is I can not access the Ember Data store after the ajax call is complete. When I try to access the store I get the following error:

Uncaught ReferenceError: store is not defined(…)

Any ideas what the issue is?




Aucun commentaire:

Enregistrer un commentaire