Tá o seguinte erro:
TypeError: Cannot read property 'query' of undefined
at C:\Users\pedro\casadocodigo\app\routes\produtos.js:8:15
at Layer.handle [as handle_request] (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\pedro\casadocodigo\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\index.js:275:10)
at expressInit (C:\Users\pedro\casadocodigo\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request] (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\layer.js:95:5)
eis o código:
TypeError: Cannot read property 'query' of undefined
at C:\Users\pedro\casadocodigo\app\routes\produtos.js:8:15
at Layer.handle [as handle_request] (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\pedro\casadocodigo\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\index.js:275:10)
at expressInit (C:\Users\pedro\casadocodigo\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request] (C:\Users\pedro\casadocodigo\node_modules\express\lib\router\layer.js:95:5)
e a exportação do módulo:
var mysql = require('mysql');
module.exports = function(){
var connection = mysql.createConnection({
host: "localhost",
user:"root",
password: "8016",
database:"casadocodigo_nodejs",
});
};