@foundatiofx/fetchclient
Version:
A typed JSON fetch client with middleware support for Deno, Node and the browser.
42 lines (28 loc) • 1.5 kB
Markdown


[](https://www.npmjs.com/package/@foundatiofx/fetchclient)
[](https://jsr.io/@foundatiofx/fetchclient)
[](https://github.com/foundatiofx/foundatio/actions)
[](https://discord.gg/6HxgFCx)
FetchClient is a tiny, typed wrapper around `fetch` with JSON helpers, caching,
middleware, rate limiting, timeouts, and friendly error handling.
## Install
```bash
npm install @foundatiofx/fetchclient
```
## Quick Example
```ts
import { FetchClient } from "@foundatiofx/fetchclient";
type Products = { products: Array<{ id: number; name: string }> };
const client = new FetchClient();
const { data } = await client.getJSON<Products>(
`https://dummyjson.com/products/search?q=iphone&limit=10`,
);
console.log(data?.products.length);
```
## Documentation
- Guide & Examples: <https://fetchclient.foundatio.dev>
- Getting Started, Usage Examples, Contributing
- API Reference: <https://jsr.io/@foundatiofx/fetchclient/doc>
---
MIT © [Foundatio](https://exceptionless.com)