김태희

routes.js 추가

1 +exports.register = function (req, res) {
2 + // console.log("req", req.body);
3 + var today = new Date();
4 + var users = {
5 + "first_name": req.body.first_name,
6 + "last_name": req.body.last_name,
7 + "email": req.body.email,
8 + "password": req.body.password,
9 + "created": today,
10 + "modified": today
11 + }
12 + connenction.query('INSERT INTO users SET ?' , users, function (error, results, fields) {
13 + if (error) {
14 + console.log("error ocurred", error);
15 + res.send({
16 + "code" : 400,
17 + "failed": "error ocurred"
18 + })
19 + } else {
20 + console.log('The solution is: ', results);
21 + res.send({
22 + "code": 200,
23 + "success": "user registered sucessfully"
24 + });
25 + }
26 + });
27 +}