# tra-typed-fetch

> A package that implements common http requests using fetch, allowing for typed responses with typescript

Latest version **1.4.1** (published 2020-12-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install tra-typed-fetch
pnpm add tra-typed-fetch
yarn add tra-typed-fetch
bun add tra-typed-fetch
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2020-12-01 |
| First published | 2020-11-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 40.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Theodore Anderson |
| Maintainers | andersontr15 |
| Keywords | fetcher, isomorphic-fetch, typed-fetch, typescript-fetch |

## Links

- npm: https://www.npmjs.com/package/tra-typed-fetch
- npm.io page: https://npm.io/package/tra-typed-fetch

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) 2.0.3
- [isomorphic-fetch](https://npm.io/package/isomorphic-fetch.md) 3.0.0

## 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

- 1.4.1 (latest) — 2020-12-01
- 1.4.0 — 2020-12-01
- 1.3.8 — 2020-12-01
- 1.3.7 — 2020-11-30
- 1.3.6 — 2020-11-30
- 1.3.5 — 2020-11-30
- 1.3.4 — 2020-11-30
- 1.3.3 — 2020-11-30
- 1.3.2 — 2020-11-30
- 1.3.1 — 2020-11-30
- 1.3.0 — 2020-11-30
- 1.2.9 — 2020-11-30
- 1.2.8 — 2020-11-30
- 1.2.7 — 2020-11-30
- 1.2.6 — 2020-11-30
- … 25 more at https://npm.io/package/tra-typed-fetch/versions

## README

# tra-typed-fetch

## Table of Contents

- [About](#about)
- [Installing](#installing)
- [Usage](#installing)

## About <a name = "about"></a>

A package that implements common http requests using fetch, allowing for typed responses with TypeScript.

### Installing <a name = "installing"></a>

`npm install tra-typed-fetch`

`yarn add tra-typed-fetch`

### Usage <a name = "usage"></a>

```ts
import { createHttpClient, get } from '@tra/typed-fetch';

interface Product {
  name: string;
  id: number;
}

type Products = Product[];

const response = await get<Products>({ url: '/products' });

// Where data will be the typed value bound to the function in the Response
const { data, headers, status } = response;

/* 
Optional exported method to preset headers and baseUrl on each request
Note: currently only supports 1 http client. Existing calls to this function will return cached http client if exists.
*/
interface IRequestConfiguration {
  baseUrl?: string;
  defaultHeaders?: Request['headers'];
}

const { baseConfiguration, get, destroy, patch, post, put } = createHttpClient({
  baseUrl: 'localhost:3000/api/v1/',
  defaultHeaders: new Headers({ 'content-type': 'application/json' }),
});
```

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