How can I prevent the sending of ember data to the server?


I've a route which user can pick more options for your account. But when I enter on this route, ember send a GET to my API. How I avoid this since I've the information I need.

I'm using Ember JS 2x.

import Ember from 'ember';

export default Ember.Route.extend({
    searchPlaces: Ember.inject.service(),
    model() {
    afterModel(model) {
        let token = model.get('token');
        let places = model.get('places');

        this.set('places', places);
        this.set('token', token);

First, I recommend reading the DS.Store API docs. There are four methods that seem relevant:

  • findRecord -- returns a Promise, tries memory first, then an API call
  • findAll -- like findRecord, but for all records of a type
  • peekRecord -- returns the record if it's in memory already, or null if not; doesn't make an API call
  • peekAll -- returns an Array of the records of a type that are already in memory

I suspect you want to call store.peekRecord or store.peekAll in your route if you want to avoid the API lookup.