Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 834 Bytes

README.md

File metadata and controls

33 lines (27 loc) · 834 Bytes

Fetch

The Go http.Transport interface implemented over the WHATWG Fetch API using the WebAssembly arch target.

Usage

This package requires the Go WASM compilation target to be supported. Short example:

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))

See my wasm-experiments repo for the full example of its use.

Attribution

The code is largely based on the Fetch API implementation in GopherJS.