27 lines
731 B
JavaScript
27 lines
731 B
JavaScript
const http = require('http');
|
|
const id = '7985cf2a-e51d-4596-91b7-40f25bedb0c2';
|
|
const data = JSON.stringify({ firmenname: 'Taeger IT' });
|
|
const opts = {
|
|
hostname: 'localhost',
|
|
port: 3001,
|
|
path: '/api/auftragsnachweise/' + id + '/pdf',
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', 'Content-Length': data.length }
|
|
};
|
|
const req = http.request(opts, r => {
|
|
let d = '';
|
|
r.setEncoding('binary');
|
|
r.on('data', c => d += c);
|
|
r.on('end', () => {
|
|
console.log('Status:', r.statusCode);
|
|
if (d.length > 1000) {
|
|
console.log('PDF size:', d.length, 'bytes - OK');
|
|
} else {
|
|
console.log('Response:', d);
|
|
}
|
|
});
|
|
});
|
|
req.on('error', e => console.error(e));
|
|
req.write(data);
|
|
req.end();
|