# How to get the user fields in a theme component?

**URL:** https://meta.discourse.org/t/how-to-get-the-user-fields-in-a-theme-component/209809
**Category:** Development
**Created:** [November 22, 2021, 4:55am UTC](https://meta.discourse.org/t/how-to-get-the-user-fields-in-a-theme-component/209809 "2021-11-22T04:55:46Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![a.pinjari](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@a.pinjari](https://meta.discourse.org/u/a.pinjari)
#### Post date: [November 22, 2021, 4:55am UTC](https://meta.discourse.org/t/how-to-get-the-user-fields-in-a-theme-component/209809/1 "2021-11-22T04:55:47Z")

</div>

We are trying to create the widget (“banner-title”) which will display the first-name of the User (we have created first-name as user field).  
In the widget, we are fetching the user first name (user\_field) using the below code:

```plaintext
let res [];
let currentUser = api.getCurrentUser();
let userfields = null;
if (currentUser) {
    api.container.lookup('store:main').find('user', currentUser.username).then((user) => {
       userfields = user.user_fields;
    });

  if(userfields ){
   //some code
   return res;
  }
}

```

Here find() executes in an async manner so the problem is every time we are getting user fields as null. how to get the user fields in a synchronized manner so we can get the value of userfields before the widget is rendered.

Thanks.
