# Are there any examples in Discourse of decorating a widget after an ajax request?

**URL:** <https://meta.discourse.org/t/are-there-any-examples-in-discourse-of-decorating-a-widget-after-an-ajax-request/44175>\
**Category:** Development\
**Created:** [Maio 12, 2016, 9:57pm UTC](https://meta.discourse.org/t/are-there-any-examples-in-discourse-of-decorating-a-widget-after-an-ajax-request/44175 "2016-05-12T21:57:31Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Overgrow](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overgrow/32/478189_2.png) [@Overgrow](https://meta.discourse.org/u/Overgrow)\
**Post date:** [Novembro 26, 2016, 2:15pm UTC](https://meta.discourse.org/t/are-there-any-examples-in-discourse-of-decorating-a-widget-after-an-ajax-request/44175/2 "2016-11-26T14:15:56Z")

</div>

I’d like to follow up on this thread. Is it possible to return results of ajax.then() to html function so it will display in widget rendered content?

The problem is that value is returned without waiting for ajax result.

```
export default createWidget('custom-widget', {
  html(attrs, state) {
    ajax("/customdata.json").then(data => {
      // some data formatting to html
      return `THIS WONT BE SHOWN`;
    });
    return `THIS IS SHOWN`;
  }
});

```

---

_[View the full topic](https://meta.discourse.org/t/are-there-any-examples-in-discourse-of-decorating-a-widget-after-an-ajax-request/44175)._
