Difference between response.body and body in node request

Viewed 972

Trying to learn the node request package. Say if I do a post request:

var request = require('request');
request.post({url: url, form: {key:'value'}}, function(err,response,body){ /* ... */ })

When I check the response.body.html() and body.html(), they seem to be the same. Is this correct? And also they seem to be both the original page where I send the data from instead of a response page I expected. Why would this happen? When I use python requests package, and post with the same data to the same url, I got different things. Can somebody enlighten what is happening here?


Edit: the python code that works as expected:

import requests
response = requests.post(url, {
    "key": "value",
     // ... there can be other pairs of key-values
})

response.content 

response.content gives me the result I need.

0 Answers
Related