Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marwan-at-work/wasm-fetch
Web Assembly fetch wrapper that avoids importing net/http.
https://github.com/marwan-at-work/wasm-fetch
Last synced: 14 days ago
JSON representation
Web Assembly fetch wrapper that avoids importing net/http.
- Host: GitHub
- URL: https://github.com/marwan-at-work/wasm-fetch
- Owner: marwan-at-work
- License: mit
- Created: 2018-10-26T21:06:56.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-18T22:25:38.000Z (over 1 year ago)
- Last Synced: 2024-05-01T14:25:26.605Z (7 months ago)
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 56
- Watchers: 2
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WASM-FETCH
[![GoDoc](https://godoc.org/marwan.io/wasm-fetch?status.svg)](https://godoc.org/marwan.io/wasm-fetch)A go-wasm library that wraps the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/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
```golang
package mainimport (
"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.