Accessing stores inside service?


#1

First of all am new to ember …

I am creating an ember service like the below and wanna use ember data for some functionalities is it possible ?

  import Ember from 'ember';
  export default Ember.Service.extend({
  init() {
    this._super(...arguments);
     this.get('store')
    console.log(this.get('store')); //undefined
  }
});

How can i access stores inside service ?


#2

You just needs to inject the store service.

```js
import Ember from 'ember';

export default Ember.Service.extend({
  store: Ember.inject.service(),

  init() {
    this._super(...arguments);
  
  console.log(this.get('store'));
  }
});