# Access store inside component

**URL:** <https://discuss.emberjs.com/t/access-store-inside-component/11182>\
**Category:** Uncategorized\
**Created:** [July 17, 2016, 5:01pm UTC](https://discuss.emberjs.com/t/access-store-inside-component/11182 "2016-07-17T17:01:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghoshnirmalya](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ghoshnirmalya/32/12423_2.png) [@ghoshnirmalya](https://discuss.emberjs.com/u/ghoshnirmalya)\
**Post date:** [July 17, 2016, 5:01pm UTC](https://discuss.emberjs.com/t/access-store-inside-component/11182/1 "2016-07-17T17:01:59Z")

</div>

I’ve the following code:

```
export default Ember.Component.extend({
  store: Ember.inject.service(),
  types: ['Task', 'Discussion', 'Note'],
  projects: this.get('store').find('user', 1).then(user => user.get('projects')),
  actions: {
    save() {
      ...
    }
  }
})

```

I want to access store in line 4 like `projects: this.get('store').find('user', 1).then(user => user.get('projects'))`.

How can I do that?

---

<div class="post-metadata">

**Author:** ![niconel](https://avatars.discourse-cdn.com/v4/letter/n/e480ec/32.png) [@niconel](https://discuss.emberjs.com/u/niconel)\
**Post date:** [July 17, 2016, 5:14pm UTC](https://discuss.emberjs.com/t/access-store-inside-component/11182/2 "2016-07-17T17:14:11Z")

</div>

I got this in a component and works fine (actually several…each just a “property” with data coming from the store

Still a n00b though, don’t know why you got “then”? Might have misunderstood!

```
  ...
  
  store: Ember.inject.service(),

  dealtypes: Ember.computed({
      get() {
      // Since we are using Ember.inject.service, we need to call the store using the get helper
          return this.get('store').findAll('dealtype');
      }
  }).readOnly(),
  ....

```

---

<div class="post-metadata">

**Author:** ![c9dw5er](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@c9dw5er](https://discuss.emberjs.com/u/c9dw5er)\
**Post date:** [April 27, 2017, 9:30pm UTC](https://discuss.emberjs.com/t/access-store-inside-component/11182/3 "2017-04-27T21:30:16Z")

</div>

This works but when I try a promise version below

/app/template/component/awesome-component.hbs

```
<ul>
  {{#each (await countryProp) as |elem|}}
    <li>{{elem.name}}</li>
  {{/each}}
</ul>

```

/app/components/awesome-component.js

```
import Ember from 'ember';

export default Ember.Component.extend({

  store: Ember.inject.service(),
  countryProp: Ember.computed('countries', function() {
    return this.get('countryTask').perform();
  }),

  countryTask: task(function*() {
    const countries = yield this.get('store').findAll('country');
    return countries;
  })

});

```

The error is ‘components/awesome-component.js: line 18, col 16, ‘task’ is not defined.’

Any help appreciated as I am a complete noob with ember.

---

<div class="post-metadata">

**Author:** ![Bauke](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/bauke/32/12190_2.png) [@Bauke](https://discuss.emberjs.com/u/Bauke)\
**Post date:** [May 1, 2017, 3:00pm UTC](https://discuss.emberjs.com/t/access-store-inside-component/11182/4 "2017-05-01T15:00:10Z")

</div>

Add this import:

```auto
import { task } from 'ember-concurrency';

```

---

<div class="post-metadata">

**Author:** ![c9dw5er](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@c9dw5er](https://discuss.emberjs.com/u/c9dw5er)\
**Post date:** [May 5, 2017, 8:51am UTC](https://discuss.emberjs.com/t/access-store-inside-component/11182/5 "2017-05-05T08:51:41Z")

</div>

> [@Bauke](#):
>
> import { task } from ‘ember-concurrency’;

Thanks, I installed the library, it built successfully but the application page is blank, the console has no errors
