Answer the question
In order to leave comments, you need to log in
How to send json over http?
There are two servers, how to send a request from the second server to the first server:
const http = require('http');
http.createServer((req, res)=>{
}).listen(1337);
const http = require("http");
const request = http.request({
'host': 'localhost',
'port': 1337,
'path': '/',
'method': 'POST'
});
request.on('response', function (res) {
res.on('data', function(data){
console.log(data);
});
})
request.end();
Answer the question
In order to leave comments, you need to log in
request.write(JSON.stringify({hello:"world"}));
request.end();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question