Nodejs reported an error connecting mysql

  node.js, question

Enter the account number and password, compare them with mysql, and go to the home page if correct.
database.js:

var mysql = require('mysql');
 var config = require('../config/config');
 
 var pool = mysql.createPool(config.mysql_dev);
 
 var query=function(sql,callback){
 pool.getConnection(function(err,conn){
 If(err) console.log("POOL == > "plus err);
 else{
 conn.query(sql,function(qerr,vals,fields){
 //Release connection
 conn.release();
 
 
 //Event Driven Callback
 callback(qerr,vals,fields);
 
 });
 bracket
 });
 };
 
 module.exports=query;

index.js:

router.post('/login',function(req,res){
 
 var query = require('../modules/database');
 query("select * from managers where ManagerID =10001",function(err,vals,fields){
 
 if(req.body.password==="admin")
 bracket
 res.redirect('/home');
 
 bracket
 Res.send ('wrong id or password!'  );
 
 });
 
 });

Always report mistakes:

/opt/workspace/project/nodejs-demo/node_modules/mysql/lib/protocol/Parser.js:77
 throw err;  // Rethrow non-MySQL errors
 ^
 
 Error: Can't set headers after they are sent.
 at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11)
 at ServerResponse.header (/opt/workspace/project/nodejs-demo/node_modules/express/lib/response.js:718:10)
 at ServerResponse.send (/opt/workspace/project/nodejs-demo/node_modules/express/lib/response.js:163:12)
 at /opt/workspace/project/nodejs-demo/routes/index.js:40:7
 at Query._callback (/opt/workspace/project/nodejs-demo/modules/database.js:16:17)
 at Query.Sequence.end (/opt/workspace/project/nodejs-demo/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
 at Query._handleFinalResultPacket (/opt/workspace/project/nodejs-demo/node_modules/mysql/lib/protocol/sequences/Query.js:144:8)
 at Query.EofPacket (/opt/workspace/project/nodejs-demo/node_modules/mysql/lib/protocol/sequences/Query.js:128:8)
 at Protocol._parsePacket (/opt/workspace/project/nodejs-demo/node_modules/mysql/lib/protocol/Protocol.js:280:23)
 at Parser.write (/opt/workspace/project/nodejs-demo/node_modules/mysql/lib/protocol/Parser.js:73:12)

I don’t know what went wrong. If the code is not clear, I can add it again.

Don’t send after redirect.

router.post('/login',function(req,res){
 
 var query = require('../modules/database');
 query("select * from managers where ManagerID =10001",function(err,vals,fields){
 
 if(req.body.password==="admin")
 bracket
 res.redirect('/home');
 return;  ///Add a return here
 bracket
 Res.send ('wrong id or password!'  );
 
 });
 
 });