title: Cannot read property 'query' of undefined Node js
body: <p>I am making an api in node js I have my mysql database, for the tests I use postman but I get the following error</p>
  <p>I have inserted data in my table so I want to recover it</p>
  <p>Cannot read property 'query' of undefined</p>
  <p>this is the code of the connection to the database</p>
  <pre><code>const mysql = require('mysql');
  
  const pool = mysql.createPool({
      host: '127.0.0.1',
      port: '3306',
      user: 'root',
      password: 'root',
      database: 'tienda',
  
  })
  
  async function getConnection() {
      try{
          const connection = await pool.getConnection();
          return connection;
      }catch (error){
          console.log(error);
      }
  }
  module.exports = {getConnection};
  </code></pre>
  <p>This code is from my get request where it sends me the error about the query I hope you can help me I do not understand what the error is</p>
  <pre><code>const express = require('express')
  const app = express()
  
  const pool = require('./database')
  
  app.get('/producto', async  (req, res) =&gt; {
      try{
          const  conn = await pool.getConnection();
          const consulta = &quot;SELECT * FROM producto&quot;;
          const resultado = await conn.query(consulta);
          res.status(200).json(resultado);
      }catch (error){
          console.log(error);
      }
  });
  
  app.post('/nuevoProducto', async (req, res) =&gt; {
      console.log(req.body);
      const conn = await pool.getConnection();
      const query = 'insert into producto value (?)';
      const resultado = conn.query(query, [req.body.name]);
      res.status(200).json(resultado);
  })
  
  
  app.listen(3000, () =&gt; {
      console.log('server on port', 3000);
  })
  </code></pre>
  <p>error obtained
  TypeError: Cannot read property 'query' of undefined</p>