@@ -2,43 +2,43 @@ const handlebars = require("express-handlebars");
22var app = require ( 'express' ) ( ) ;
33app . engine ( '.hbs' , handlebars ( { defaultLayout : 'main' , extname : '.hbs' } ) ) ;
44app . set ( 'view engine' , '.hbs' )
5- app . post ( '/path' , function ( req , res ) {
5+ app . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
66 var bodyParameter = req . body . bodyParameter ;
77 res . render ( 'template' , bodyParameter ) ; // NOT OK
88} ) ;
99
1010var app2 = require ( 'express' ) ( ) ;
11- app2 . post ( '/path' , function ( req , res ) {
11+ app2 . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
1212 var bodyParameter = req . body . bodyParameter ;
1313 res . render ( 'template' , bodyParameter ) ; // OK
1414} ) ;
1515
1616var app3 = require ( 'express' ) ( ) ;
1717app3 . set ( 'view engine' , 'pug' ) ;
18- app3 . post ( '/path' , function ( req , res ) {
18+ app3 . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
1919 var bodyParameter = req . body . bodyParameter ;
2020 res . render ( 'template' , bodyParameter ) ; // OK
2121} ) ;
2222
2323var app4 = require ( 'express' ) ( ) ;
2424app4 . set ( 'view engine' , 'ejs' ) ;
25- app4 . post ( '/path' , function ( req , res ) {
25+ app4 . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
2626 var bodyParameter = req . body . bodyParameter ;
2727 res . render ( 'template' , bodyParameter ) ; // NOT OK
2828} ) ;
2929
3030var app5 = require ( 'express' ) ( ) ;
3131app5 . engine ( "foobar" , require ( "consolidate" ) . whiskers ) ;
3232app5 . set ( 'view engine' , 'foobar' ) ;
33- app5 . post ( '/path' , function ( req , res ) {
33+ app5 . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
3434 var bodyParameter = req . body . bodyParameter ;
3535 res . render ( 'template' , bodyParameter ) ; // NOT OK
3636} ) ;
3737
3838var app6 = require ( 'express' ) ( ) ;
3939app6 . register ( ".html" , require ( "consolidate" ) . whiskers ) ;
4040app6 . set ( 'view engine' , 'html' ) ;
41- app6 . post ( '/path' , function ( req , res ) {
41+ app6 . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
4242 var bodyParameter = req . body . bodyParameter ;
4343 res . render ( 'template' , bodyParameter ) ; // NOT OK
4444} ) ;
@@ -47,7 +47,7 @@ const express = require('express');
4747var router = express . Router ( ) ;
4848var app7 = express ( ) ;
4949app7 . set ( 'view engine' , 'ejs' ) ;
50- router . post ( '/path' , function ( req , res ) {
50+ router . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
5151 var bodyParameter = req . body . bodyParameter ;
5252 res . render ( 'template' , bodyParameter ) ; // NOT OK
5353} ) ;
0 commit comments