2.5.1 • Published 3 years ago

@brendanatme/wrap-fetch v2.5.1

Weekly downloads
29
License
ISC
Repository
github
Last release
3 years ago

Wrap Fetch

Wrap a fetch API to simplify GET, POST, UPDATE, DELETE requests

Usage

import { wrapFetch } from '@brendanatme/wrap-fetch';

const myFetchFunction = fetch;
const myBaseUrl = 'http://localhost:3000';
const myOptions = {
  headers: {
    'x-api-key': 'myApiKey, etc.',
  },
};

const beforeHook = (method, url) => console.log(`myApi: ${method} ${url}`);

const myApi = wrapFetch(myFetchFunction, myBaseUrl, myOptions, beforeHook);

// ...

const got = await myApi.get('/my-get-endpoint');

// ...

const posted = await myApi.post('/my-post-endpoint', {
  foo: 'bar',
});
2.3.0

3 years ago

2.5.0

3 years ago

2.4.1

3 years ago

2.4.0

3 years ago

2.3.1

3 years ago

2.5.1

3 years ago

2.2.3

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago