mirror of
https://github.com/taigrr/wasm-experiments
synced 2025-01-18 04:03:21 -08:00
30 lines
413 B
Go
30 lines
413 B
Go
// +build js,wasm
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"net/http"
|
|
|
|
"github.com/johanbrandhorst/fetch"
|
|
)
|
|
|
|
func main() {
|
|
c := http.Client{
|
|
Transport: &fetch.Transport{},
|
|
}
|
|
resp, err := c.Get("https://api.github.com")
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer resp.Body.Close()
|
|
b, err := ioutil.ReadAll(resp.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(b))
|
|
}
|