0.0.1-alpha.2 • Published 3 years ago
octofetch v0.0.1-alpha.2
Documentation
You can find the full documentation here: Documentation
How does it work
OctoFetch is a thin layer on top of the browser native Fetch API, which is supported in all modern browsers and polyfilled by most tools such as Nuxt.js, Next.js, create-react-app, vue-cli, etc. It allows for much less boilerplate and more reusable code.
OctoFetch is made for browser, but can be used in Node.JS using the package isomorphic-fetch
for polyfilling the native Fetch API.
Install the package
Using NPM:
npm install octofetch --save
Using YARN
yarn add octofetch
Simple usage
Javascript
import octofetch from "octofetch";
octofetch()
.get("https://localhost:5000/api/users/:id")
.path("id", userId)
.header("Token", "Bearer my-token-here")
.fetch()
.then((user) => console.log(`Got user: ${user}`))
.catch((error) => console.log(error.code));
Typescript
import octofetch from "octofetch";
const users = await octofetch<User[]>().get("https://localhost:5000/api/users").fetch();