Code files
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
'use strict'
|
||||
|
||||
const http = require('http')
|
||||
const payload = `{
|
||||
"name": "Cian Ó Maidín",
|
||||
"company": "nearForm"
|
||||
}`
|
||||
const opts = {
|
||||
method: 'POST',
|
||||
hostname: 'reqres.in',
|
||||
port: 80,
|
||||
path: '/api/users',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': Buffer.byteLength(payload)
|
||||
}
|
||||
}
|
||||
|
||||
const req = http.request(opts, (res) => {
|
||||
console.log('\n Status: ' + res.statusCode)
|
||||
process.stdout.write(' Body: ')
|
||||
res.pipe(process.stdout)
|
||||
res.on('end', () => console.log('\n'))
|
||||
})
|
||||
|
||||
req.on('error', (err) => console.error('Error: ', err))
|
||||
|
||||
req.end(payload)
|
||||
Reference in New Issue
Block a user