Skip to content

ipromax/wasm-fetch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WASM-FETCH

GoDoc

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.

About

Web Assembly fetch wrapper that avoids importing net/http.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%