NodeJs how to display table structured in console

前端 未结 3 1464
温柔的废话
温柔的废话 2021-02-07 10:38

Is it possible without installing new package?

Here i am using cli-table package..

Any easy way to do it ?

3条回答
  •  没有蜡笔的小新
    2021-02-07 11:02

    node.js version v10.16.0, you can use console.table API without installing any node module.

    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:

提交回复
热议问题