# Getting the global state in my model

**URL:** <https://discourse.aurelia.io/t/getting-the-global-state-in-my-model/5321>\
**Category:** Help Requests\
**Created:** [December 11, 2023, 1:55pm UTC](https://discourse.aurelia.io/t/getting-the-global-state-in-my-model/5321 "2023-12-11T13:55:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vladyn](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/vladyn/32/2473_2.png) [@vladyn](https://discourse.aurelia.io/u/vladyn)\
**Post date:** [December 11, 2023, 1:55pm UTC](https://discourse.aurelia.io/t/getting-the-global-state-in-my-model/5321/1 "2023-12-11T13:55:43Z")

</div>

Hi guys,  
I’m trying to get my state in my component. class, where I need to dispatch an action and update the state after an HTTP service wrapper receives a successful response. I’m following the docs [`state` binding command and state change](https://discourse.aurelia.io/t/state-binding-command-and-state-change/5131) from here, where I can see my state in the view, but I can’t import / inject the global state in my sidebar component.  
I would highly appreciate it if someone could help with a tip here. I’m using Aurelia 2.

---

<div class="post-metadata">

**Author:** ![vladyn](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/vladyn/32/2473_2.png) [@vladyn](https://discourse.aurelia.io/u/vladyn)\
**Post date:** [December 11, 2023, 2:57pm UTC](https://discourse.aurelia.io/t/getting-the-global-state-in-my-model/5321/2 "2023-12-11T14:57:30Z")

</div>

I found `keywords & state`, which works for the view, but what If I want to do the following:

```auto
async attached() {
    await httpService.getCases()......
    store.dispatch({type: "updateCases", value: response})
}              

```

how can I get the updated state after the dispatch?

---

<div class="post-metadata">

**Author:** ![dwaynecharrington](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/dwaynecharrington/32/11_2.png) [@dwaynecharrington](https://discourse.aurelia.io/u/dwaynecharrington)\
**Post date:** [December 12, 2023, 2:26am UTC](https://discourse.aurelia.io/t/getting-the-global-state-in-my-model/5321/3 "2023-12-12T02:26:56Z")

</div>

Hi Vladyn,

Correct me if I am misunderstanding. But, I believe you’re after the `fromState` decorator which is detailed in the docs [here](https://docs.aurelia.io/aurelia-packages/state#with-fromstate-decorator).

```auto
export class AutoSuggest {
  @fromState(state => state.cases)
  keywords: string;
}

```

Let me know how you go.

---

<div class="post-metadata">

**Author:** ![vladyn](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/vladyn/32/2473_2.png) [@vladyn](https://discourse.aurelia.io/u/vladyn)\
**Post date:** [December 12, 2023, 7:39pm UTC](https://discourse.aurelia.io/t/getting-the-global-state-in-my-model/5321/4 "2023-12-12T19:39:21Z")

</div>

Hi @dwaynecharrington,  
Thanks for the tip. I actually tried this, but I had a small misstyping. This one works perfectly. I had to fix my **eslint** configuration regarding this post: [Eslint Error: Parsing error: Unexpected character '@' · Issue #13502 · eslint/eslint · GitHub](https://github.com/eslint/eslint/issues/13502).
