hapi-bodyparser
Hapi.js body parsing plugin support merge querystring, sub objects and sanitizer.
Parse incoming request bodies in a plugin before your handlers, available under the request.payload (body: true --> request.body) property.
If you don't know Node.js
Node.js Tutorial for Beginners in 2020
How To Build a Blog with Nest.js, MongoDB, and Vue.js
Machine Learning In Node.js With TensorFlow.js
npm install hapi-bodyparser --save
// Not set if you want default optionsoptions: // parser options use qs.parse(value, options) parser: allowDots: true strictNullHandling: true sanitizer: trim: true // remove first || end white space of String stripNullorEmpty: true // remove property when Null or Empty merge: false // merge querystring into body body: false // If false: request.payload is default parsed | if true request.body is parsed
var Hapi = ; var server = ;server; server;
Options can be configured on a route via the body
plugin object.
server;
Parsing sub object for validate dynamic object keys name
server;
With option merge: true
, merge querystring into payload (body).
server;
Option sanitizer help clean object properties.
// with default options: trim: true and stripNullorEmpty: true a: ' Hello ' b: '' c: null d: 'World ' e: a: null b: 1 c:'' // after sanitize a: 'Hello' d: 'World' e: b: 1