DEV Community

Discussion on: You Don't Need Axios

Collapse
 
joshuaamaju profile image
Joshua Amaju

Never do this

const originalFetch = window.fetch
window.fetch = async (...args) => {
    // intercept request
    const res = originalFetch(...args)
    // intercept response e.g
    if(res.ok) {
        return res.json()
    } else
        //Do whatever you want to handle the error
    }
}
Enter fullscreen mode Exit fullscreen mode

That's a terrible advice

Some comments have been hidden by the post's author - find out more