@@ -2,43 +2,43 @@ const handlebars = require("express-handlebars");
2
2
var app = require ( 'express' ) ( ) ;
3
3
app . engine ( '.hbs' , handlebars ( { defaultLayout : 'main' , extname : '.hbs' } ) ) ;
4
4
app . set ( 'view engine' , '.hbs' )
5
- app . post ( '/path' , function ( req , res ) {
5
+ app . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
6
6
var bodyParameter = req . body . bodyParameter ;
7
7
res . render ( 'template' , bodyParameter ) ; // NOT OK
8
8
} ) ;
9
9
10
10
var app2 = require ( 'express' ) ( ) ;
11
- app2 . post ( '/path' , function ( req , res ) {
11
+ app2 . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
12
12
var bodyParameter = req . body . bodyParameter ;
13
13
res . render ( 'template' , bodyParameter ) ; // OK
14
14
} ) ;
15
15
16
16
var app3 = require ( 'express' ) ( ) ;
17
17
app3 . set ( 'view engine' , 'pug' ) ;
18
- app3 . post ( '/path' , function ( req , res ) {
18
+ app3 . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
19
19
var bodyParameter = req . body . bodyParameter ;
20
20
res . render ( 'template' , bodyParameter ) ; // OK
21
21
} ) ;
22
22
23
23
var app4 = require ( 'express' ) ( ) ;
24
24
app4 . set ( 'view engine' , 'ejs' ) ;
25
- app4 . post ( '/path' , function ( req , res ) {
25
+ app4 . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
26
26
var bodyParameter = req . body . bodyParameter ;
27
27
res . render ( 'template' , bodyParameter ) ; // NOT OK
28
28
} ) ;
29
29
30
30
var app5 = require ( 'express' ) ( ) ;
31
31
app5 . engine ( "foobar" , require ( "consolidate" ) . whiskers ) ;
32
32
app5 . set ( 'view engine' , 'foobar' ) ;
33
- app5 . post ( '/path' , function ( req , res ) {
33
+ app5 . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
34
34
var bodyParameter = req . body . bodyParameter ;
35
35
res . render ( 'template' , bodyParameter ) ; // NOT OK
36
36
} ) ;
37
37
38
38
var app6 = require ( 'express' ) ( ) ;
39
39
app6 . register ( ".html" , require ( "consolidate" ) . whiskers ) ;
40
40
app6 . set ( 'view engine' , 'html' ) ;
41
- app6 . post ( '/path' , function ( req , res ) {
41
+ app6 . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
42
42
var bodyParameter = req . body . bodyParameter ;
43
43
res . render ( 'template' , bodyParameter ) ; // NOT OK
44
44
} ) ;
@@ -47,7 +47,7 @@ const express = require('express');
47
47
var router = express . Router ( ) ;
48
48
var app7 = express ( ) ;
49
49
app7 . set ( 'view engine' , 'ejs' ) ;
50
- router . post ( '/path' , function ( req , res ) {
50
+ router . post ( '/path' , require ( 'body-parser' ) . json ( ) , function ( req , res ) {
51
51
var bodyParameter = req . body . bodyParameter ;
52
52
res . render ( 'template' , bodyParameter ) ; // NOT OK
53
53
} ) ;
0 commit comments