Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2019-02-22T11:51:48.768183+00:00 app[web.1]: error Error: Undefined
- binding(s) detected when compiling FIRST query: select * from "users"
- where "id" = ? limit ?
- 2019-02-22T11:51:48.768200+00:00 app[web.1]: at QueryCompiler_PG.toSQL
- (/app/node_modules/knex/lib/query/compiler.js:85:13)
- exports.up = function (knex, Promise) {
- return knex.schema.createTable('users', users => {
- users.increments('id')
- users.string('name').notNullable();
- users.string('email').notNullable();
- users.string('username').notNullable();
- users.string('password').notNullable();
- users.string('role').notNullable();
- })
- router.post('/signup', (req, res) => {
- const user = req.body;
- const hashedPass = bcrypt.hashSync(user.password, 12)
- user.password = hashedPass;
- var username = user.username
- db.insertUser(user)
- .then(ids => {
- const id = ids[0];
- db.findByID(id)
- .then(user => {
- const token = (newToken(user));
- res.status(200).json({ id: user.id,
- username:username,token:token});
- })
- .catch(err => {
- console.log("error", err);
- res.status(500).json({ error: 'Something went wrong' })
- })
- })
- .catch(err => {
- res.status(500).send(err);
- });
- });
- findByID: (id) => {
- return db('users').where('id', id).first();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement