Estou com um problema, sempre que eu tento acessar a url ele da um erro:
Error: Failed to lookup view "/produtos/lista" in views directory "./app/views" at EventEmitter.render (C:\Users\Lucas\Desktop\casadocodigo\node_modules\express\lib\application.js:579:17) at ServerResponse.render (C:\Users\Lucas\Desktop\casadocodigo\node_modules\express\lib\response.js:961:7) at Query._callback (C:\Users\Lucas\Desktop\casadocodigo\app\routes\produtos.js:13:8) at Query.Sequence.end (C:\Users\Lucas\Desktop\casadocodigo\node_modules\mysql\lib\protocol\sequences\Sequence.js:96:24) at Query._handleFinalResultPacket (C:\Users\Lucas\Desktop\casadocodigo\node_modules\mysql\lib\protocol\sequences\Query.js:144:8) at Query.EofPacket (C:\Users\Lucas\Desktop\casadocodigo\node_modules\mysql\lib\protocol\sequences\Query.js:128:8) at Protocol._parsePacket (C:\Users\Lucas\Desktop\casadocodigo\node_modules\mysql\lib\protocol\Protocol.js:280:23) at Parser.write (C:\Users\Lucas\Desktop\casadocodigo\node_modules\mysql\lib\protocol\Parser.js:73:12) at Protocol.write (C:\Users\Lucas\Desktop\casadocodigo\node_modules\mysql\lib\protocol\Protocol.js:39:16) at Socket. (C:\Users\Lucas\Desktop\casadocodigo\node_modules\mysql\lib\Connection.js:96:28)
meu código:
produtos.js
module.exports = function(app) {
app.get('/produtos', function(req, res) {
var mysql = require('mysql');
var connection = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "casadocodigo_nodejs",
});
connection.query('select * from livros', function(err, result) {
res.render('/produtos/lista', {lista : result});
});
connection.end();
});
}
express.js
var app = require('express')();
module.exports = function() {
app.set('view engine','ejs');
app.set('views','./app/views');
return app;
};