Pinned Solution
idiegea21
HOBBY
5 months ago
The issue happens because the query in Node.js doesn’t specify the schema (railway.vendedores) and dni may be stored as a string, causing the request to hang or return nothing.
Use the full table path and cast dni as a string in your query:
const query = 'SELECT COUNT(*) as count FROM railway.vendedores WHERE dni = ?';
db.query(query, [String(req.params.dni)], (error, results) => {
if (error) return res.status(500).json({ error: 'Error al verificar DNI' });
console.log(results);
res.json({ available: results[0].count === 0 });
});2 Replies
Railway
BOT
6 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
idiegea21
HOBBY
5 months ago
The issue happens because the query in Node.js doesn’t specify the schema (railway.vendedores) and dni may be stored as a string, causing the request to hang or return nothing.
Use the full table path and cast dni as a string in your query:
const query = 'SELECT COUNT(*) as count FROM railway.vendedores WHERE dni = ?';
db.query(query, [String(req.params.dni)], (error, results) => {
if (error) return res.status(500).json({ error: 'Error al verificar DNI' });
console.log(results);
res.json({ available: results[0].count === 0 });
});Status changed to Solved brody • 5 months ago