Reputation: 67
In My package.json files
"express": "~4.9.0",
"express-validator": "~2.7.0"
.
.
.
In my app.js file
var expressValidator = require('express-validator');
.
.
.
app.use(expressValidator);
When i go to browser, the respective page is not displayed? It is continuously loading. After remove express validator relevant code, the page render properly.
Upvotes: 0
Views: 831
Reputation: 17178
Check if you have bodyParser installed.
Express-validator recommends that it is called immediately after bodyParser in app.js.
Example:
// bodyParser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// Express-validator
app.use(expressValidator({
errorFormatter: function(param, msg, value) {
var namespace = param.split('.'),
root = namespace.shift(),
formParam = root;
while(namespace.length) {
formParam += '[' + namespace.shift() + ']';
}
return {
param : formParam,
msg : msg,
value : value
};
}
}));
Upvotes: 1
Reputation: 451
Unfortunately this is not much code to work with. But you could try it with:
app.use(expressValidator());
instead of
app.use(expressValidator);
Upvotes: 0