HTTP Request from inside WASM using Hogosuru

This example uses Hogosuru framework.

See the output in browser developer console.

Actual code:

buttonprimary.OnClick(func(e event.Event) {
    if ftch, err := fetch.New("https://httpbin.org/anything", nil); hogosuru.AssertErr(err) {
      ftch.Then(func(r response.Response) *promise.Promise {
        textpromise, _ := ftch.Then(func(r response.Response) *promise.Promise {
          if promise, err := r.Text(); hogosuru.AssertErr(err) {
            return &promise
          }
          return nil
        }, nil)
        textpromise.Then(func(i interface{}) *promise.Promise {
          fmt.Println(i.(string))
          if element, err := doc.GetElementById("outtxt"); hogosuru.AssertErr(err) {
            element.SetTextContent(i.(string))
          }
          return nil
        }, nil)
        return nil
      }, func(e error) {
        fmt.Printf("An error occured: %s\n", e.Error())
      })
    }
})

Info