How does node plus mysql plus express return the data to the front desk?

  mysql, question

图片描述
Js file linking the database

图片描述

Ejs file.

How to write articles.js so that the result of connection.js can be received by the front desk in the form of json?

app.get('/page',function(req,res){
 //Some of your codes
 pool.getConnection(function(err,connection){
 connection.query("select * from xxx",function(err,rows){
 if(!  err) {
 res.render('your page',{
 results:rows
 });
 bracket
 });
 })
 })

Major components:

res.render('your page',{
 bugs:rows
 });