I have an express js server running on port 3000 and 4000 and want to send a post request from server 3000 to server 4000
I tried this:
var post_options = {
url: "http://172.28.49.9:4000/quizResponse",
timeout: 20000,
method:"POST",
encoding: "application/json; charset=utf-8",
body : {data: formdata}
};
request(post_options,
function optionalCallback(err, httpResponse, body) {
if (err) {
console.log(err);
}else
console.log(body);
});
But getting this error:
TypeError: First argument must be a string or Buffer at ClientRequest.OutgoingMessage.write (_http_outgoing.js:456:11) at Request.write (D:\restfullApi\examineerapi\node_modules\request\request.js:1514:27) at end (D:\restfullApi\examineerapi\node_modules\request\request.js:552:18) at Immediate. (D:\restfullApi\examineerapi\node_modules\request\request.js:581:7) at runCallback (timers.js:637:20) at tryOnImmediate (timers.js:610:5) at processImmediate [as _immediateCallback] (timers.js:582:5)
This is not working as I thought. Please help me to solve this issue.