0.3.10 • Published 2 years ago

to-api v0.3.10

Weekly downloads
33
License
MIT
Repository
github
Last release
2 years ago

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.

0.3.9

2 years ago

0.3.10

2 years ago

0.3.8

2 years ago

0.3.7

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.5

6 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago