When I make a POST request to a website, the JSON response body posts 'undefined'. However, it correctly prints the response body content in the form of name/value pair objects to the console when I call console.log(body)
.
Why is the body 'undefined' when I post the content to the website?
Response body:
const options = {
method: 'GET',
url: 'https://url.com',
content: {count: '3'},
headers: {}
};
Calls to body:
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const params = {
status: request.body
}
M.post('statuses', params) => {
console.log(params.request);
};