0.1.1 • Published 6 years ago

fetch-interceptors v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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" }
  })
0.1.1

6 years ago

0.1.0

6 years ago