New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

to-api

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-api

Library `to-api` generates REST API client with [`fetch`](https://fetch.spec.whatwg.org) under the hood.

latest
Source
npmnpm
Version
0.3.10
Version published
Weekly downloads
28
2700%
Maintainers
1
Weekly downloads
 
Created
Source

to-api

Library to-api generates REST API client with fetch under the hood.

Usage

import create from 'to-api';

const clientApi = create({ baseUrl: 'http://api/users' });

clientApi
  .addHeader('Authorization', 'bearer ...')
  .processResponse(({ data }) => data);

const usersClient = clientApi({
  create: 'POST /',
  updateById: 'PUT /:id',
  deleteById: 'DELETE /:id',
  find: '/',
  findById: 'GET /:id'
});

(async () => {
    const newUser = await usersClient.create({ email: 'user@example.com' });
    const user = await usersClient.findById({ id: 'user-id' });
})();

More examples you can find in tests.

Keywords

api

FAQs

Package last updated on 04 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts