HTTP Request from inside WASM using Yaegi

This example uses Yaegi.

See the output in browser developer console.

Actual code:


package main

import (
  "fmt"; "io"; "net/http"
)

func main() {
  resp, err := http.Get("https://httpbin.org/anything")
  if err != nil {
    panic(err)
  }
  defer resp.Body.Close()
  body, _ := io.ReadAll(resp.Body)
  fmt.Println(string(body))
}

Info