@zemd/http-client
TypeScript icon, indicating that this package has built-in type declarations

4.0.1 • Public • Published

Building block for Fetch API

This is a small, zero dependencies building block for creating HTTP clients based on native fetch api. It allows you to compose your fetch function easily.

Installation

npm install @zemd/http-client
pnpm add @zemd/http-client

Usage

import { compose, method, json } from "@zemd/http-client";

const myfetch = compose([method("POST"), json()], fetch);
// ^ myfetch is a `fetch` function with configured http method and Content-Type
const resp = await myfetch("https://example.com");
// ^ calling `myfetch` is the same as calling `fetch` with the same arguments

As you can see the configuration and usage are very simple and straightforward.

Some real-world examples you can find in ../apis/ folder.

A simple example you can also find here src/example.ts

License

@zemd/http-client released under the Apache 2.0 license

Donate

Readme

Keywords

none

Package Sidebar

Install

npm i @zemd/http-client

Weekly Downloads

6

Version

4.0.1

License

Apache-2.0

Unpacked Size

19.6 kB

Total Files

5

Last publish

Collaborators

  • hunterman