3
There I go again. I have a function where a registration in the Mysql database is working. But while trying to get the data from an input I get the following error:
Typeerror: Cannot read Property 'user' of Undefined
Node:
exports.AddUser = function(request, reponse){
console.log('Email: ', reponse.body.user.email);
Model.addUser({email_usuario: Math.random() , senha_usuario:'sds' }, function(user){
reponse.render('user/add', {
title: 'cadastro'
});
});
};
Jade:
extends ../layout
block content
form(action="../user/add", method="post")
label Email
input(type="text" name="user[email]")
label senha
input(type="password" name="user[senha]")
button(type="submit") Cadastrar
br
I’ve tried with reponse.body.email
, input(type="text" name="senha")
and it didn’t work, what’s wrong here?
On what line you make that mistake?
– Sergio
Instead of
reponse.body.email
, use therequest.body.email
– Lucio Rubens
Hey guys, I was able to solve it and I just had to put the 'body-parser' module and put this 'app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ Extended: true }));'
– Liw. S.