1

I am working on a React app which makes a lot of API calls, is there a middleware which can basically intercept all calls and console them similar to Multer for Express server.

In addition, I wonder if there is a general logger for events like errors, APIs, etc. in React.

1
  • The netwrok tab can show only xhr, Commented May 6, 2020 at 15:35

1 Answer 1

1

Although, you can see the request & response data in the Chrome Network Tab, but if you still want to see it logged in the console for some reason, Yes! there is a way.

If you are using axios to make API calls, you can use interceptors. Refer to this part of axios docs. You can do a console.log in the interceptor. Or check this answer.

If you are using fetch to make API calls, you can still define a custom function. Refer to this answer.

I think this will solve your problem. Good Luck!

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.