SHARE
TWEET

Odyssey Homer 04

stevebekaert Dec 16th, 2019 277 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. const express = require('express')
  3. const router = express.Router();
  4.  
  5. const connection = require('../../helpers/db.js');
  6.  
  7. router.use(express.urlencoded({ extended: false }));
  8. router.use(express.json());
  9.  
  10. router.post('/signup', function(req, res, next) {
  11.     const answer = req.body;
  12.     console.log(answer)
  13.     console.log(req.body.email)    
  14.     connection.query('INSERT INTO users (email, password, name, lastname) VALUES (?,?,?,?)', [req.body.email, req.body.password, req.body.name, req.body.lastname], function (error, results, fields) {
  15.         if (error) {
  16.             console.log(error)
  17.             res.status(500).send("Error, see error message in server console")
  18.         } else {
  19.             res.status(200).send("")
  20.         }
  21.     });
  22. });
  23.  
  24. module.exports = router;
  25.  
  26.  
  27. /*
  28.  
  29. mysql> SELECT * from users;
  30. +----+--------------------+------------+-------+----------+
  31. | id | email              | password   | name  | lastname |
  32. +----+--------------------+------------+-------+----------+
  33. |  1 | my@email.com       | myPassw0rd | James | Bond     |
  34. |  3 | mysecond@email.com | myPassw0rd | James | Bond     |
  35. |  4 | mythird@email.com  | myPassw0rd | James | Bond     |
  36. +----+--------------------+------------+-------+----------+
  37. 3 rows in set (0.00 sec)
  38.  
  39. mysql>
  40.  
  41.  
  42. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top