我正在用node js和mysql连接lambdas到一个rds,第一次触发lambda函数时出现错误“process exited before completing request”,然后就可以正常工作了。
这是我的密码:
const mysql = require('mysql');
module.exports.selectAll = (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = false;
//Response
let response = {
status: 200,
message: '',
data: [],
}
//Body request
const {user} = event
const connection = mysql.createConnection({
host: process.env.host_DB,
user: process.env.user_DB,
password: process.env.password_DB,
database: process.env.database_DB
});
connection.open();
connection.query(`call test_db.getAll('${user != undefined? user : 0}')`,
function(err, results, fields) {
if(err){
console.log(err);
response.status = 500;
response.message = err.message;
response.data = [];
}else{
response.data = results[0];
response.message = 'Success';
}
connection.end();
callback(null, response);
})
};
知道是什么引起的吗?
暂无答案!
目前还没有任何答案,快来回答吧!