# fp-fetch

> Functional style, non-throwing fetch utils

Latest version **0.1.1** (published 2020-05-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install fp-fetch
pnpm add fp-fetch
yarn add fp-fetch
bun add fp-fetch
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2020-05-06 |
| First published | 2020-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 21 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Alexander Yanin |
| Maintainers | monstasat |
| Keywords | fetch-api, typescript, functional-programming, fp-ts |

## Links

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

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2020-05-06

## README

# fp-fetch

Functional style, non-throwing utils for data fetching

## Installation

To install the stable version:

```bash
npm install fp-fetch
```

## Usage

### Basic example

```typescript
import { isLeft } from 'fp-ts/lib/Either';
import {
  NetworkError,
  ParserError,
  ResponseError,
  fetchJSON
} from 'fp-fetch';

const result = await fetchJSON('http://example.com')();

if (isLeft(result)) {
  // handle error here
  const { left: error } = result;
  if (error instanceof NetworkError) {
    console.log(`network error occured, message=${error.message}`);
  }
  if (error instanceof ParserError) {
    console.log(`parser error occured, message=${error.message}`);
  }
  if (error instanceof ResponseError) {
    const { message, body } = error;
    console.log(`response error occured, message=${message}, body=${body}`);
  }
} else {
  // handle ok here
  const { right: payload } = result;
  console.log(`got ok response, payload=${payload}`);
};
```

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