32 lines
873 B
JavaScript
32 lines
873 B
JavaScript
const http = require('http');
|
|
const data = JSON.stringify({value: 60});
|
|
const options = {
|
|
hostname: 'localhost',
|
|
port: 7000,
|
|
path: '/api/registry/4202/write',
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Content-Length': Buffer.byteLength(data)
|
|
}
|
|
};
|
|
|
|
const req = http.request(options, (res) => {
|
|
console.log('STATUS', res.statusCode);
|
|
res.setEncoding('utf8');
|
|
res.on('data', (chunk) => console.log('BODY', chunk));
|
|
res.on('end', () => {
|
|
// fetch registries
|
|
http.get('http://localhost:7000/api/registries', (res2) => {
|
|
console.log('REG STATUS', res2.statusCode);
|
|
let body = '';
|
|
res2.setEncoding('utf8');
|
|
res2.on('data', c => body += c);
|
|
res2.on('end', () => console.log('REG BODY', body));
|
|
});
|
|
});
|
|
});
|
|
req.on('error', (e) => console.error('REQ ERR', e));
|
|
req.write(data);
|
|
req.end();
|