# Getting data for the widget

**URL:** https://meta.discourse.org/t/getting-data-for-the-widget/95632
**Category:** Development
**Created:** [August 25, 2018, 4:26pm UTC](https://meta.discourse.org/t/getting-data-for-the-widget/95632 "2018-08-25T16:26:08Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Stranik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stranik/32/85638_2.png) [@Stranik](https://meta.discourse.org/u/Stranik)
#### Post date: [August 25, 2018, 4:26pm UTC](https://meta.discourse.org/t/getting-data-for-the-widget/95632/1 "2018-08-25T16:26:09Z")

</div>

I don’t want to use this approach in widgets:

```plaintext
$.ajax({
  url: "/u/"+ username +".json", 
  dataType: 'json',
  async: false,
  success: function(data) {
	
  ....data.user.time_read;

```

Is there any other way to get this variable: `time_read`? This is an example.

from the template

`discourse/app/assets/javascripts/discourse/templates/discovery.hbs`

through

```plaintext
{{plugin-outlet name="discovery-list-container-top"
                        args=(hash category=category listLoading=loading)}}

```

no data is transmitted.

Is there any other way (other than json) to get this data (time\_read, badge\_count etc.)

_Extras._ `currentUser` does not have this data.

Thank

---

<div class="post-metadata">

### Author: ![gdpelican](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gdpelican/32/81308_2.png) [@gdpelican](https://meta.discourse.org/u/gdpelican)
#### Post date: [August 25, 2018, 4:55pm UTC](https://meta.discourse.org/t/getting-data-for-the-widget/95632/2 "2018-08-25T16:55:22Z")

</div>

Do you only need it for the current user?

---

<div class="post-metadata">

### Author: ![Stranik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stranik/32/85638_2.png) [@Stranik](https://meta.discourse.org/u/Stranik)
#### Post date: [August 25, 2018, 4:57pm UTC](https://meta.discourse.org/t/getting-data-for-the-widget/95632/3 "2018-08-25T16:57:25Z")

</div>

Yes. Only for this user.

---

<div class="post-metadata">

### Author: ![gdpelican](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gdpelican/32/81308_2.png) [@gdpelican](https://meta.discourse.org/u/gdpelican)
#### Post date: [August 25, 2018, 5:02pm UTC](https://meta.discourse.org/t/getting-data-for-the-widget/95632/4 "2018-08-25T17:02:33Z")

</div>

You might try something like this:

```plaintext
DiscoursePluginRegistry.serialized_current_user_fields << 'recent_time_read'

```

to add it to the serialized current user.

```plaintext
User.current().recent_time_read

```

Keep in mind that this will only be serialized once, on app load, and that to get an updated value you’ll either need to query for it directly, or use MessageBus to ‘live update’ the user’s read\_time.

---

<div class="post-metadata">

### Author: ![Stranik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stranik/32/85638_2.png) [@Stranik](https://meta.discourse.org/u/Stranik)
#### Post date: [August 25, 2018, 6:06pm UTC](https://meta.discourse.org/t/getting-data-for-the-widget/95632/5 "2018-08-25T18:06:18Z")

</div>

> [@gdpelican](#):
>
> to query for it directly

What is the best way to do that is with minimal load.?

> [@gdpelican](#):
>
> DiscoursePluginRegistry.serialized\_current\_user\_fields \<\< ‘recent\_time\_read’

This method is not quite suitable.
