How to obtain the store in an application initializer?

I need to query from the store before the application boots and I want to use the app.deferReadiness() and app.advanceReadiness(). I’d like to use the store because it gets returned in json api format and i’d rather use ember data for this instead of writing a jquery.ajax call.

I’ve tried app.lookup and container.lookup and this function does not exist. Will I have to resort to private methods to make this happen?

I basically need to do the following:

export function initialize(container, app) {
   * console.log(container.lookup); // undefined
   * console.log(app.lookup); // undefined
  const store = container.lookup('store:main');

  store.findRecord('config', '105-1').then(data => {
    // handle stuff
  }).catch(err => {
    // handle error

export default {
  name: 'my-initializer',
  after: 'store',

Perhaps do something like this:

This.get(‘store’) is not available in an initializer

Hum. I try to understand this but store seems to be injected. Perhaps write after: "store"?? (Edit: I see you tried that)

See also this old commends:

Answer: You can’t in an application initializer, because the application has not been initialized yet. Instead you should use an instance initializer, which does provide you with the desired lookup function.

See: Initializers - Application Concerns - Ember Guides

1 Like