modulepackage
0.1.0
Repository: https://github.com/marwan-at-work/wasm-fetch.git
Documentation: pkg.go.dev
# README
WASM-FETCH
A go-wasm library that wraps the Fetch API
Install
go get marwan.io/wasm-fetch
Motivation
Importing net/http adds ~4 MBs to your wasm binary. If that's an issue for you, you can use this library to make fetch calls.
Example
package main
import (
"context"
"time"
"marwan.io/wasm-fetch"
)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
resp, err := fetch.Fetch("/some/api/call", &fetch.Opts{
Body: strings.NewReader(`{"one": "two"}`),
Method: fetch.MethodPost,
Signal: ctx,
})
// use response...
Status
GO-WASM is currently experimental and therefore this package is experimental as well, things can break unexpectedly.
# Functions
CanonicalHeaderKey returns the canonical format of the header key s.
Fetch uses the JS Fetch API to make requests over WASM.
# Constants
cache enums.
cache enums.
cache enums.
cache enums.
cache enums.
cache enums.
credentials enums.
credentials enums.
credentials enums.
Common HTTP methods.
Common HTTP methods.
Common HTTP methods.
Common HTTP methods.
Common HTTP methods.
RFC 5789.
Common HTTP methods.
Common HTTP methods.
Common HTTP methods.
Mode enums.
Mode enums.
Mode enums.
Mode enums.
Redirect enums.
Redirect enums.
Redirect enums.
Referrer enums.
Referrer enums.
ReferrerPolicy enums.
ReferrerPolicy enums.
ReferrerPolicy enums.
ReferrerPolicy enums.
ReferrerPolicy enums.
# Type aliases
A Header represents the key-value pairs in an HTTP header.