Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
Las rutas expresas no envían respuesta Heroku-Postgres código H12

Tengo un problema con mis rutas que no envían respuestas a la interfaz. Solo tengo 3 rutas hasta ahora, solo dos envían respuestas, pero ninguna lo está haciendo. Estoy usando node-postgres (pg). Mi ruta de registro parece estar funcionando porque cuando registro un usuario, se refleja en la base de datos. Aquí están las dos rutas en cuestión.

 // login app.post('/api/v1/login', checkInput, async (req, res, next) => { console.log(req.body) try { // find user db.query(`SELECT * FROM users WHERE username = $1`, [req.body.username], async (err, user) => { if (err) throw err; // user not found if (!user) { res.send({message: 'error'}); } else { // compare passwords const matchedPassword = await bcrypt.compare(req.body.password, user.password); // password doesn't match if (!matchedPassword) { res.send({message: 'error'}); } else { // user found req.session.user = user.username; req.session.auth = true; res.send({message: 'success'}); } } }) } catch (error) { next(error); } }); // register app.post('/api/v1/register', checkInput, async (req, res, next) => { console.log(req.body) try { // check if user already exists db.query(`SELECT username FROM users WHERE username = $1`, [req.body.username], (err, user) => { if (err || user) { res.send({message: 'error'}); } }); // user doesn't exist so create user // encrypt password const salt = await bcrypt.genSalt(3); const hashPassword = await bcrypt.hash(req.body.password, salt); db.query(`INSERT INTO users (username, password) VALUES ($1, $2)`, [req.body.username, hashPassword], (err, user) => { if (err) { res.send({message: 'error'}); } else { res.send({message: 'success'}); } }); } catch (error) { next(error); } });

¡Cualquier ayuda sería apreciada!

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!