https://github.com/kiritaniayaka/fetcha
https://github.com/kiritaniayaka/fetcha
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kiritaniayaka/fetcha
- Owner: KiritaniAyaka
- License: mit
- Created: 2024-06-17T03:57:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-16T03:49:08.000Z (11 months ago)
- Last Synced: 2025-04-27T21:03:27.721Z (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
[](https://www.npmjs.com/package/@kiritaniayaka/fetcha)
[](https://www.npmjs.com/package/@kiritaniayaka/fetcha)
[](https://jsr.io/@kiritaniayaka/fetcha)
[](https://jsr.io/@kiritaniayaka/fetcha)
[](https://bundlephobia.com/package/@kiritaniayaka/fetchaa)
[](https://www.jsdocs.io/package/@kiritaniayaka/fetcha)
[](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)