diff --git a/fetch/fetch/fetch.go b/fetch/fetch/fetch.go index c9c9868..b1a9a66 100644 --- a/fetch/fetch/fetch.go +++ b/fetch/fetch/fetch.go @@ -1,10 +1,14 @@ +// +build js,wasm + package fetch import ( + "fmt" "io" "net/http" "net/url" - "runtime/js" + "syscall/js" + "syscall/js/callback" ) type Method int @@ -61,6 +65,11 @@ func Fetch(req Request) (Response, error) { } init.Set("headers", headers) + cb := callback.New(func(args []js.Value) { + fmt.Println(args) + }) + promise := js.Global.Call("fetch", req.URL.String(), init) + promise.Call("then", cb) return Response{}, nil } diff --git a/fetch/main.go b/fetch/main.go index fa89c9b..9459111 100644 --- a/fetch/main.go +++ b/fetch/main.go @@ -1,3 +1,5 @@ +// +build js,wasm + package main import (