Yttrium Body Parser
This package wraps the Express body-parser package to make it usable by the YttriumJS web framework.
Installation
npm install yttbody --save
How To Use
The Yttrium server exposes the use
method to add plugins. Add the body parsing plugin like this:
const Y = ;const parseBody = ; const $ server router = ;;
This will expose a parseBody
method on the jQuery object (regardless of the name used when importing the body parser).
To parse a request body, use the parseBody
method in one of your route handlers:
$ ; $ ;
API
$(req).parseBody(parser, options)
parser
is one of the four parsers supported by body-parser:
- json
- raw
- text
- urlencoded
options
accepts any parser-specific options as documented in the body-parser README.
Note: body-parser has deprecated the use of urlencoded
without the { extended: true }
option set. This package auto sets { extended: true }
when using the urlencoded
parser.