In a Node.js
server routes get request data as follows:
router.get(
'/dog',
(req, res) => {
req.something...
}
)
For debugging purposes, I want to inspect what gets sent as the req
object for a call like the following:
fetch(/app/dog)
.then(...)
Is there a way for me to access the req
parameters before the request is sent? (Presumably I could do such debugging in my route, but I’m wanting to perform this inspection before making the fetch call). Thanks!
2
Answers
The short version is ‘no’. The
req
parameter gets created after the request is sent by the client, and after it’s headers are received by the server.If you’re using axios, you may want to investigate interceptors in your front end: https://axios-http.com/docs/interceptors
Easy way to log outgoing requests or make some modifications to them.