Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. 2019-02-22T11:51:48.768183+00:00 app[web.1]: error Error: Undefined
  2. binding(s) detected when compiling FIRST query: select * from "users"
  3. where "id" = ? limit ?
  4. 2019-02-22T11:51:48.768200+00:00 app[web.1]: at QueryCompiler_PG.toSQL
  5. (/app/node_modules/knex/lib/query/compiler.js:85:13)
  6.  
  7. exports.up = function (knex, Promise) {
  8. return knex.schema.createTable('users', users => {
  9. users.increments('id')
  10. users.string('name').notNullable();
  11. users.string('email').notNullable();
  12. users.string('username').notNullable();
  13. users.string('password').notNullable();
  14. users.string('role').notNullable();
  15. })
  16.  
  17. router.post('/signup', (req, res) => {
  18. const user = req.body;
  19. const hashedPass = bcrypt.hashSync(user.password, 12)
  20. user.password = hashedPass;
  21. var username = user.username
  22. db.insertUser(user)
  23. .then(ids => {
  24. const id = ids[0];
  25. db.findByID(id)
  26. .then(user => {
  27. const token = (newToken(user));
  28. res.status(200).json({ id: user.id,
  29. username:username,token:token});
  30. })
  31. .catch(err => {
  32. console.log("error", err);
  33. res.status(500).json({ error: 'Something went wrong' })
  34. })
  35. })
  36. .catch(err => {
  37. res.status(500).send(err);
  38. });
  39. });
  40.  
  41. findByID: (id) => {
  42. return db('users').where('id', id).first();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement