Open travis-w opened 4 years ago
I can't think of any way to access all the headers sent, but here you can find the default node-fetch headers (and when they are set).
Hope this helps.
Thanks for the response. The only issue with just having those, is that content-length is computed, so I would have to calculate it myself in order to log that. And then there is a chance, unless I basically just strip out certain parts of node-fetch into my own code, that the headers I calculate, are still different than the ones node-fetch sends.
For anyone that has a similar need, I ended up switching to sindresorhus/got. It has a hook, that allows you to inspect the request right before it is sent.
As a reference:
NODE_DEBUG=http
Is there a good way to view the final request headers that are sent in the fetch request?
I am working on a library that uses node-fetch to send http requests and I was trying to set up some http level logging, so it would be nice to log out what exact headers are sent in the request. I am able to log the user set headers, however node-fetch generates the default headers if they don't exist so I would like to log those as well.
Is there a good way to get these? Or do I basically need to recreate the getNodeRequestOptions for my own use if I want to keep using node-fetch? Or maybe it would be possible to get this function exported at the module level for util use?
Thanks!