M
M
mamont802017-06-25 14:07:31
Node.js
mamont80, 2017-06-25 14:07:31

How to get outgoing traffic from request object in node js?

There is a popular package https://github.com/request/request, it's easy to set parameters and get a response. How can I get the raw data that this request sends to the server? It is clear that I know what parameters I set, but I would like it completely, in its raw form as it is, along with headers and other things.

var request = require('request');
request('http://www.google.com', function (error, response, body) {
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dark Hole, 2017-06-25
@abyrkov

1. See README
2. See in " Debugging ":
3. We look at request-debug and see in " Usage ":

require('request-debug')(request, function(type, data, r) {
    // put your request or response handling logic here
});
If you specify your own handling function, r will be the Request instance that generated the event, and type will be one of the following values:
request - Headers were sent to the server and will be included as data.headers. data.body may also be present for POST requests.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question