This simple snippet demonstrates how to use Node to make a POST request.
const https = require('http')
const data = JSON.stringify({
doc_set_1: 'hello'
})
const options = {
hostname: 'ec2-instance-dns.com',
port: '8000',
path: '/textsim',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
}
const req = https.request(options, (res) => {
console.log(`statusCode: ${res.statusCode}`)
.on(
res'data', (d) => {
process.stdout.write(d)
}
)
})
.on('error', (error) => {
reqconsole.error(error)
})
.write(data)
req.end() req