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

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`;
  }
});