1
0
mirror of https://github.com/taigrr/wasm-experiments synced 2025-01-18 04:03:21 -08:00
2018-05-13 00:32:35 +01:00

21 lines
366 B
Go

// +build js,wasm
package main
import (
"syscall/js"
"syscall/js/callback"
)
func main() {
wait := make(chan struct{})
promise := js.Global.Call("fetch", "https://api.github.com")
promise.Call("then", callback.New(func(args []js.Value) {
response := args[0]
r := response.Get("body").Call("getReader")
r.Call("read")
close(wait)
}).Value)
<-wait
}