leef-js
v0.3.0
Published
![CI](https://github.com/frankdilo/leef-js/workflows/CI/badge.svg) ![NPM version](https://badgen.net/npm/v/leef-js) ![Bundle size (minified + g-zipped)](https://badgen.net/bundlephobia/minzip/leef-js)
Downloads
12
Readme
🍃 Leef
⚠️ This is currently a work-in-progress. I am learning TypeScript as I go!
Lightweight, type-safe HTTP client based on Fetch API, with an API similar to axios.
Installation
npm install leef-js
yarn add leef-js
Basic Usage
import leef from "leef-js";
const res = await leef.get("https://api.github.com/users/frankdilo");
console.log(res.data.login); // => "frankdilo"
console.log(res.status); // => 200
Methods
leef.get(url, options);
leef.post(url, data, options);
leef.put(url, data, options);
leef.patch(url, data, options);
leef.delete(url, options);
leef.head(url, options);
leef.options(url, options);
Build and instance
import leef from "leef-js";
const api = leef.instance({
baseURL: "https://api.example.com"
headers: {
Authorization: `Bearer ${process.env.AUTH_TOKEN}`,
},
});
await api.get("/users");
Options
baseURL
headers
timeout
bodySerializer
defaultContentType