0.0.6 • Published 1 year ago

@mvdlei/web v0.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Web package

Web package with pre-configured fetch for HTTP API requests.

Installation

npm install @mvdlei/web

Usage

import { api } from "@mvdlei/web";

api.get("https://api.example.com/data").then((response) => console.log(response));

With body

api("https://api.example.com/data", {
  method: "POST",
  body: { example: "example" },
}).then((data) => console.log(data));

Can throw:

try {
  const data = await api("https://api.example.com/data", {
    method: "POST",
    body: { example: "example" },
  });
} catch (error) {
  if (HttpError.is(error)) {
    // handle http error
    error.response;
  }
}

License

MIT

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago