gobits
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

Gobits

An extensible Javascript HTTP Client that wraps Fetch API and provides middlewares, with Typescript support.
You can add middlewares (even asynchronous ones) to Gobits to add more features.

Install

Using npm

npm i gobits

or with yarn

yarn add gobits

Quick start

const simpleAuth = (req, res, next) => {
    req.headers['Authorization'] = `Bearer ABCD-EFGH`;
    return next();
}
const responseLogger = (req, res, next, responded) => {
    if (responded){ // After receiving the response from fetch (2. pass)
        console.log('Response:', res.body);   
    }
    return next();
}

const go = new Gobits();
go.use(simpleAuth);
go.use(responseLogger);

const users = go.get<User[]>("http://restapi.adequateshop.com/api/users")
    .then(response => response.body);

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i gobits

Weekly Downloads

0

Version

0.2.2

License

MIT

Unpacked Size

63.6 kB

Total Files

15

Last publish

Collaborators

  • necrobits