Estoy realizando una aplicación, donde uso NodeJs y MySQL, sin embargo a pesar de que ya me pude conectar a la base de datos e insertar registros, al realizar un Select desde una ruta diferente me envia el siguiente error.
Server on Port 4000 DB is Connected <ref *1> Query { _events: [Object: null prototype] {}, _eventsCount: 0, _maxListeners: undefined, _callback: undefined, _callSite: Error at Pool.query (C:\wamp\www\nodejsAppMySQL\node_modules\mysql\lib\Pool.js:199:23) at C:\wamp\www\nodejsAppMySQL\src\routes\links.js:27:49 at Layer.handle [as handle_request] (C:\wamp\www\nodejsAppMySQL\node_modules\express\lib\router\layer.js:95:5) at next (C:\wamp\www\nodejsAppMySQL\node_modules\express\lib\router\route.js:137:13) at Route.dispatch (C:\wamp\www\nodejsAppMySQL\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (C:\wamp\www\nodejsAppMySQL\node_modules\express\lib\router\layer.js:95:5) at C:\wamp\www\nodejsAppMySQL\node_modules\express\lib\router\index.js:281:22 at Function.process_params (C:\wamp\www\nodejsAppMySQL\node_modules\express\lib\router\index.js:335:12) at next (C:\wamp\www\nodejsAppMySQL\node_modules\express\lib\router\index.js:275:10) at Function.handle (C:\wamp\www\nodejsAppMySQL\node_modules\express\lib\router\index.js:174:3), _ended: false, _timeout: undefined, _timer: Timer { _object: [Circular *1], _timeout: null }, sql: 'SELECT * FROM links', values: undefined, typeCast: true, nestTables: false, _resultSet: null, _results: [], _fields: [], _index: 0, _loadError: null, [Symbol(kCapture)]: false }
Les adjunto mi codigo por si alguien sabe cual es mi problema:
const express = require('express');
const router = express.Router();
const pool = require ('../database');
router.get('/add', (req,res) =>
{
// res.send('form');
res.render('links/add');
});
router.post('/add', async (req,res) =>
{
const {title,url, description} = req.body;
const newLink = { title
,url
,description};
await pool.query('INSERT INTO links set ?', [newLink]);
res.send('enviado');
});
router.get('/', async (req, res) =>
{
const links = await pool.query('SELECT * FROM links');
console.log(links);
res.send('las listas iran Aqui');
});
module.exports = router;
El problema se presenta al ejecutar esta
router.get('/', async (req, res) =>
{
cont links = await pool.query('SELECT * FROM links');
console.log(links);
res.send('las listas iran Aqui');
});