3

I have an adapter that queries a url using user specific data. I need a way to get data from the simple auth session to the adapter.

I tried to inject the session into the adapter Adapter

session: Ember.inject.service('session'),

But this is throwing an error

Error while processing route: videos.index Attempting to inject an unknown injection: service:session Error: Attempting to inject an unknown injection: service:session

Edit:

In the adapter I can retrieve the user data via the container.

Adapter:

var container = this.get('container');
var currentUser = container.lookup('session:withCurrentUser');
console.log('currentUser ID', currentUser.get('secure.userData.id'));

Would this be the recommended way to do it?

Wez
  • 61
  • 5

1 Answers1

1

First, you'd only need

session: Ember.inject.service(),

Ember knows from the variable name that you need the 'session' service.

Anyhow, I'd recommend to create an initializer where you inject your session into the adapter.

//initializer/adapter.js
App.inject('adapter', 'session', 'service:session');
Nicolas
  • 269
  • 4
  • 14