NodeJs how to display table structured in console
You can use console.table() API without installing any node module. NodeJS Added in: v10.0.0, Browser compatibility
const structDatas = [
{ handler: 'http', endpoint: 'http://localhost:3000/path', method: 'ALL' },
{ handler: 'event', endpoint: 'http://localhost:3000/event', method: 'POST' },
{ handler: 'GCS', endpoint: 'http://localhost:3000/GCS', method: 'POST' }
];
console.table(structDatas);
The stdout in terminal like this:
var values = [];
Array.forEach(function(b, i) {
values.push(
{
'Symbol': b.a,
'BID': b.b,
'CONVERT1': b.c,
'Buy': b.d,
'Sell': b.e,
'Convert2': b.f
});
});
console.table(values);
Result Console