# simple-fetch-wrapper

> Fetch wrapper

Latest version **1.3.8** (published 2020-07-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install simple-fetch-wrapper
pnpm add simple-fetch-wrapper
yarn add simple-fetch-wrapper
bun add simple-fetch-wrapper
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.8 |
| Published | 2020-07-08 |
| First published | 2020-06-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Christoffer Öhman |
| Maintainers | chrillaz |
| Keywords | fetch, http, ajax |

## Links

- npm: https://www.npmjs.com/package/simple-fetch-wrapper
- Repository: https://github.com/Chrillaz/simple-fetch-wrapper
- Homepage: https://github.com/Chrillaz/simple-fetch-wrapper#readme
- Issues: https://github.com/Chrillaz/simple-fetch-wrapper/issues
- npm.io page: https://npm.io/package/simple-fetch-wrapper

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.3.8 (latest) — 2020-07-08
- 1.3.7 — 2020-07-08
- 1.3.6 — 2020-07-08
- 1.3.5 — 2020-07-06
- 1.3.4 — 2020-07-03
- 1.3.3 — 2020-07-03
- 1.3.2 — 2020-06-30
- 1.3.0 — 2020-06-30
- 1.1.5 — 2020-06-17
- 1.1.4 — 2020-06-17
- 1.1.3 — 2020-06-15
- 1.1.2 — 2020-06-15
- 1.1.1 — 2020-06-15
- 1.0.17 — 2020-06-14
- 1.0.16 — 2020-06-13
- … 15 more at https://npm.io/package/simple-fetch-wrapper/versions

## README

# Simple Fetch Wrapper

Simple wrapper around fetch. 

For own purposes initially...

GET and POST 

### Use
```
npm i simple-fetch-wrapper
```

```
import http from 'simple-fetch-wrapper'
```

### API Examples

```
   import http from 'simple-fetch-wrapper'

   http.setBaseUrl(url: string);

   http.setDefaultContentType('application/json');

   const url = http.getBaseUrl('/api/v1/endpoint');
   
   http.interceptor(requestConfig => {

      console.log(requestConfig);

      requestConfig.headers.append('Authorization', `Bearer ${token}`);

      return requestConfig;
   })

   http.isFetching(status: boolean) => console.log(status));

   http.on('customEvent', (data) => console.log(data));

   http.emit('customEvent', data);

   http.detach('customEvent', Function);
```

### Supports GET and POST

```
   const args = {
      params: {post: 71}
   };

   const response = await http.get(url, args)


   const args = {
      headers: {'Content-Type': 'application/json'},
      body: {name: 'Some name', id: 1}
   }; 

   const response = await http.post(url, args);
```

### Args

| Properties   | Type                     |
|--------------|:------------------------:|
| headers      | {[key: string]: string}  |
| body         | {[key: string]: any}     |
| params       | {[key: string]: any}     |

---
_Source: https://npm.io/package/simple-fetch-wrapper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
