mirror of
https://github.com/taigrr/wasm-experiments
synced 2025-01-18 04:03:21 -08:00
35 lines
499 B
Go
35 lines
499 B
Go
// +build js,wasm
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/johanbrandhorst/fetch"
|
|
)
|
|
|
|
func main() {
|
|
c := http.Client{
|
|
Transport: &fetch.Transport{},
|
|
}
|
|
resp, err := c.Post(
|
|
"https://httpbin.org/anything",
|
|
"application/json",
|
|
strings.NewReader(`{"test":"test"}`),
|
|
)
|
|
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))
|
|
}
|