Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kiritaniayaka/fetcha
https://github.com/kiritaniayaka/fetcha
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/kiritaniayaka/fetcha
- Owner: KiritaniAyaka
- License: mit
- Created: 2024-06-17T03:57:30.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-08-16T03:49:08.000Z (5 months ago)
- Last Synced: 2024-12-02T01:19:17.616Z (about 2 months ago)
- Language: TypeScript
- Size: 81.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fetcha
[![NPM Version](https://img.shields.io/npm/v/%40kiritaniayaka%2Ffetcha?style=flat&colorA=080f12&colorB=1fa669)](https://www.npmjs.com/package/@kiritaniayaka/fetcha)
[![npm downloads](https://img.shields.io/npm/dy/%40kiritaniayaka%2Ffetcha?style=flat&colorA=080f12&colorB=1fa669)](https://www.npmjs.com/package/@kiritaniayaka/fetcha)
[![JSR](https://jsr.io/badges/@kiritaniayaka/fetcha)](https://jsr.io/@kiritaniayaka/fetcha)
[![JSR Score](https://jsr.io/badges/@kiritaniayaka/fetcha/score)](https://jsr.io/@kiritaniayaka/fetcha)
[![bundle](https://img.shields.io/bundlephobia/minzip/%40kiritaniayaka%2Ffetcha?style=flat&colorA=080f12&colorB=1fa669&label=minzip)](https://bundlephobia.com/package/@kiritaniayaka/fetchaa)
[![JSDocs](https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669)](https://www.jsdocs.io/package/@kiritaniayaka/fetcha)
[![License](https://img.shields.io/github/license/KiritaniAyaka/fetcha.svg?style=flat&colorA=080f12&colorB=1fa669)](https://github.com/KiritaniAyaka/fetcha/blob/main/LICENSE)A minimal fetch client wrapper with interceptor.
## Examples
```ts
const baseUrl = 'http://localhost:8000'const fetcha = new FetchaBuilder()
.useRequestInterceptor((info, init) => { // base url example
return [`${baseUrl}${info}`, init]
})
.useResponseInterceptor(async (response) => { // interceptor could be async
if (!response.ok())
return toast('Some thing went wrong')
return await response.json()
})
.build() // build a fetcha clientfetcha('/api/hello') // use it like fetch
```## License
[MIT](./LICENSE) License © 2024 [Kiritani Ayaka](https://github.com/KiritaniAyaka)