Express view helper that displays all kinds of data (post, query, string, params, cookies, session).
npm install express-var-dumpThe Express version of PHP's
var_dump(). It lets you
output information in JSON format regarding cookies, session data, query params,
route params, post data and request headers by default.
This is a Node.js module available through the
npm registry. Installation is done using thenpm install command:
``bash`
npm install express-var-dump
First add the view helper to your app:
`js
// app.js
const { addVarDumpViewHelper } = require('express-var-dump');
const app = require('express')();
// ..define express middleware && other stuff before..
app.use(addVarDumpViewHelper);
// ..define express routing after..
`
Then in your view call varDump() (using ejs templating engine below):
`html`
<%- varDump() %>
Output:
varDump(arrayOfProperties, object): html
You can also use varDump directly to generate prettified JSON data to HTMLExpress
code for any object (in it defaults to the request object and the
properties detailed in the description).
`js
const { varDump } = require('express-var-dump');
const packageData = require('./package.json');
console.log(varDump(['name', 'version', 'author', 'dependencies'], packageData));
// outputs HTML code generated with pretty-print-json``
That allows you to use the module with other Node.js web apps that don't use
Express.