How to prevent ember-data from making a request to the server

0

I have a route where the person can select items from a list for their account. But when entering this route ember sends a GET request to the server. How could I prevent this from happening?

Follow the code snippet. I'm using EmberJS 2x

import Ember from 'ember';

export default Ember.Route.extend({
    searchPlaces: Ember.inject.service(),
    model() {
        return this.store.findAll('user');
    },
    afterModel(model) {
        let token = model.get('token');
        let places = model.get('places');

        this.set('places', places);
        this.set('token', token);
    }
});
    
asked by anonymous 09.02.2016 / 13:58

1 answer

0

According to this response from SOEN

The problem is to use findAll instead of peekRecord or peekAll . When reading the documentation on DS.store we can find the following cases.

  • findRecord - fetch a promise, first query in memory and then on server if it is not found .
  • findAll - Similar to findRecord , but query all.
  • peekRecord - returns the result of the item that is already in memory, or null if not found; does not query the server.
  • Relate Item - returns an Array with the results found that are already in memory.
09.02.2016 / 14:05