@kiritaniayaka/fetcha
v0.1.1
Published
A minimal fetch client wrapper with interceptor.
Downloads
6
Maintainers
Readme
fetcha
A minimal fetch client wrapper with interceptor.
Examples
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 client
fetcha('/api/hello') // use it like fetch
License
MIT License © 2024 Kiritani Ayaka