Answer the question
In order to leave comments, you need to log in
How to change current page and pass parameters to Node.js (Express)?
There is a code that processes data from the user registration form
let usersModel = require('../models/users');
exports.create = function(request, response) {
usersModel.findByEmail(request.body.email, function(error, result) {
if (error) {
console.log(error);
return response.render('pages/index', {
createUser: {
code: 500,
first_name: request.body["first-name"],
last_name: request.body["last-name"],
email: request.body.email,
region: request.body.region
}
});
}
if (result) {
return response.render('pages/index', {
createUser: {
code: 210,
first_name: request.body["first-name"],
last_name: request.body["last-name"],
email: request.body.email,
region: request.body.region
}
});
}
let users = {
first_name: request.body["first-name"],
last_name: request.body["last-name"],
email: request.body.email,
region: request.body.region
};
usersModel.create(users, function(error, result) {
if (error) {
console.log(error);
return response.render('pages/index', {
createUser: {
code: 500,
first_name: request.body["first-name"],
last_name: request.body["last-name"],
email: request.body.email,
region: request.body.region
}
});
}
return response.render('pages/index', {
createUser: {
code: 200
}
});
});
});
};
return response.render('pages/index', {
createUser: {
code: 200
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question