I am using axios for a react application and I would like to log all axios calls that I'm making anywhere in the app. I'm already using a single global instance of axios via the create function and I am able to log a generic console.log. However I would like more info like function being called, parameters, etc.
相关问题
- How to toggle on Order in ReactJS
- Refreshing page gives Cannot GET /page_url in reac
- Adding a timeout to a render function in ReactJS
- Axios OPTIONS instead of POST Request. Express Res
- React Native Inline style for multiple Text in sin
相关文章
- Why would we use useEffect without a dependency ar
- Is it possible to get ref of props.children?
- Stateless function components cannot be given refs
- React testing library: Test attribute / prop
- React/JestJS/Enzyme: How to test for ref function?
- Material-UI [v0.x] RaisedButton on hover styles
- Remove expo from react native
- ReactJS toLowerCase is not a function
It looks like you can intercept all requests using an "interceptor", and log inside of it: https://github.com/mzabriskie/axios#interceptors
You can try wrap the
axios.request
function in a Promise.Use axios-logger
When you send a request in nodejs, you need to show the log to the console.
Here's an NPM package for MySQL that let's you log all axios requests https://www.npmjs.com/package/axios-logger-mysql , I hope this helps.
The best way to do this would be an interceptor. Each interceptor is called before a request/response. In this case a logging interceptor would be.
or something to that effect.
It's good that you're using a new instance of axios:
That way you can call
Use
axios-debug-log
npm install --save axios-debug-log
require('axios-debug-log')
before any axios callDEBUG=axios
By default, you'll see logs like the following:
Refer to the docs for configuration and customization options.