0.1.1 • Published 6 years ago
fetch-interceptors v0.1.1
fetch() Response Interceptors
Wrap JavaScript's fetch()
to add response interceptors.
import withInterceptors from 'fetch-interceptors'
const wrappedFetch = withInterceptors(
fetch,
({ request, ...response }) => {
return {
...response,
// moar props
}
},
response => {
// 🤒
return response
}
)
wrappedFetch('https://httpbin.org/get?foo=bar')
.then(response => {
console.log(response)
// { "foo": "bar" }
})