asking for information to my sql database with node.js

I am following a tutorial of how to connect my app to mysql database, but at this point, my program does not work out as it used to be.

this is the function to select the rows from jugadores and render it on the view

const router = express.Router();     const pool = mysql.createPool   router.get('/', async(req, res) => {     const jugadores = await pool.query('SELECT * FROM jugadores');     console.log(jugadores)     res.render('jugadores/list', { jugadores: jugadores }) }); 

the console show this:

Query {   _events: [Object: null prototype] {},   _eventsCount: 0,   _maxListeners: undefined,   _callback: undefined,   _callSite: Error       at Pool.query (C:\Users\Jehan\Desktop\Proyecto_chess\node_modules\mysql\lib\Pool.js:199:23)       at C:\Users\Jehan\Desktop\Proyecto_chess\src\routes\jugadores.js:24:34       at Layer.handle [as handle_request] (C:\Users\Jehan\Desktop\Proyecto_chess\node_modules\express\lib\router\layer.js:95:5)       at next (C:\Users\Jehan\Desktop\Proyecto_chess\node_modules\express\lib\router\route.js:137:13)       at Route.dispatch (C:\Users\Jehan\Desktop\Proyecto_chess\node_modules\express\lib\router\route.js:112:3)       at Layer.handle [as handle_request] (C:\Users\Jehan\Desktop\Proyecto_chess\node_modules\express\lib\router\layer.js:95:5)       at C:\Users\Jehan\Desktop\Proyecto_chess\node_modules\express\lib\router\index.js:281:22       at Function.process_params (C:\Users\Jehan\Desktop\Proyecto_chess\node_modules\express\lib\router\index.js:335:12)       at next (C:\Users\Jehan\Desktop\Proyecto_chess\node_modules\express\lib\router\index.js:275:10)       at Function.handle (C:\Users\Jehan\Desktop\Proyecto_chess\node_modules\express\lib\router\index.js:174:3),   _ended: false,   _timeout: undefined,   _timer: Timer { _object: [Circular], _timeout: null },   sql: 'SELECT * FROM jugadores',   values: undefined,   typeCast: true,   nestTables: false,   _resultSet: null,   _results: [],   _fields: [],   _index: 0,   _loadError: null } 

how can I do to show the jugadores variables? PD: the tutorial shows how this console.log give it back the rows of the table jugadores in the database

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.