1

In angular there is one feature call HttpInterceptor which intercepts Http request and it helps in converting http request before sending and after getting the response from the server. Is there something similar in React Js??

I would like to have the code centralised so that can be managed from one place.

2
  • 1
    Not in React itself. There are error boundaries, and there are a lot of libraries that can help with that, but React itself does not have such a mechanism. Commented Jul 6, 2020 at 22:25
  • What Jonas said. I recommend using something like axios to create interceptors. Commented Jul 6, 2020 at 22:26

1 Answer 1

1

React doesn't do http calls. It's just a UI library. For data fetching you can use fetch, axios, etc. Axios has interceptors: https://github.com/axios/axios#interceptors

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.