Problem accessing initializer from an adapter

I’m having a problem accessing an initializer from an adapter.

Adapter:

import DS from 'ember-data';

export default DS.RESTAdapter.extend({
	host: this.config.api.baseURL
});

Initializer:

import config from '../config/environment';

export function initialize(container, application) {
  application.register('config:main', config, {instantiate: false});

  application.inject('route', 'config', 'config:main');
  application.inject('controller', 'config', 'config:main');
  application.inject('adapter', 'config', 'config:main');
}

export default {
	name: 'config',
	initialize: initialize
};

There’s no “this” as you’re inside a plain object, not a function. Rather than accessing the initializer, what you should do is get it from config:

import DS from 'ember-data';
import ENV from '../config/environment';

export default DS.RESTAdapter.extend({
  host: ENV.APP.api.baseURL
});


// config/environment.js

APP: {
  // Here you can pass flags/options to your application instance
  // when it is created
  api: {
    baseURL: ...
  }
}