Skip to content

johnnynotsolucky/fetch-interceptors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Wrap JavaScript's fetch function to add response interceptors.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published