I'm trying to work with nodejs without a framework to get a more detailed idea of how the node works.
This code is as follows: I make a request in the database and I pass the result to the renderFile to be able to send the object to the page, so that I can style the page with the data of the database.
Do you have a problem with this code?
Is it a wrong way to go this way, without using any framework?
function onFunction(req,res){
con.query('SELECT * FROM barbeiro', function(err,result,fields){
ejs.renderFile('./index.ejs',{data: result},(err,html) => {
res.writeHead(200, {'Content-type':'text/html'});
res.write(html);
res.end();
});
});
}