Skip to content

twilic/fetch

Repository files navigation

@twilic/fetch

Fetch helpers for Twilic binary request and response bodies.

Install

pnpm add @twilic/fetch @twilic/core

Usage

import { twilicFetchJson } from "@twilic/fetch";

const data = await twilicFetchJson("/api/users", {
  method: "POST",
  twilicBody: { id: 1n, name: "alice" },
});

In the browser, call init({ prefer: "wasm" }) from @twilic/core before using these helpers.

API

  • TWILIC_CONTENT_TYPE
  • twilicFetch(input, init?)
  • parseTwilicResponse(response, options?)
  • twilicFetchJson(input, init?)
  • createTwilicFetch(codec?, fetchImpl?)

Runnable example

pnpm example:http-roundtrip          # any server from twilic/examples
pnpm example:http-roundtrip:client   # this package

See http-roundtrip/.

Changelog

See docs/CHANGELOG.md.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Fetch helpers for Twilic binary request and response bodies.

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages