HTTP Request from inside WASM using Nigel2392/requester library

This example uses Nigel2392/requester library for Golang.

See the output in browser developer console.

Actual code:

var client = requester.NewAPIClient()
ch := make(chan struct{})
client.Get("https://httpbin.org/anything").Do(func(response *http.Response) {
  defer response.Body.Close()

  body, err := io.ReadAll(response.Body)
  if err == nil {
    fmt.Println(string(body))
  } else {
    fmt.Println(err)
  }

  ch <- struct{}{}
})
<-ch

Info