# icfetcher

> Library to facilitate the creation of reusable fetchers

Latest version **1.1.0** (published 2023-02-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install icfetcher
pnpm add icfetcher
yarn add icfetcher
bun add icfetcher
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2023-02-18 |
| First published | 2023-01-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | ignacio.cuadra |

## Links

- npm: https://www.npmjs.com/package/icfetcher
- npm.io page: https://npm.io/package/icfetcher

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21

## Recent versions

- 1.1.0 (latest) — 2023-02-18
- 1.0.1 — 2023-01-22
- 1.0.0 — 2023-01-21

## README

# [icfetcher](https://github.com/ignacio-cuadra/icfetcher) [![npm version](https://img.shields.io/npm/v/icfetcher.svg?style=flat)](https://www.npmjs.com/package/react)

icfetcher is a JavaScript library for creating fetchers using fetch method with a variety of settings.

## Usage

```javascript
const fetcher = ({ url, method, body }) => {
  return fetchFactory({
    baseUrl: "https://pokeapi.co/api/v2",
    isJson: true, // Content-Type and Accept header = application/json
    url,
    method, // GET (default)
    body,
    autoBodyStringfy: true, // parse array to json string
    autoClearUndefinedBodyAttributes: true // remove nulls attributes
})

// without fetch wrapper
fetcher({url: '/pokemon/magikarp'})
  .then(response => response.json())  
  .then((response) => {
      console.log(response.forms[0].name)
    })
    .catch(error => console.log(error))

// with fetch wrapper
fetchWrapper(fetcher({url: '/pokemon/magikarp'}))
  .then(({status, data}) => {
    console.log(status ,data.forms[0].name)
  })
  .catch(error => console.log(error))
// catch and throw errors and transform result to json
```

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