I am running this following register user function in my node js web app. I need to get the result of the query to out from the con.connection() function. is there a way to do it in javascript to return a value from an asynchronous function.
const con=require('../connection');
class User{
static async registerUser(NIC,first_name, middle_name, last_name, email,state, address_no,street, phone_number, user_name, password)
{
con.query('insert into Personal_information (NIC, first_name,middle_name,
last_name,address_no,street, state,phone_number, email,user_name, password)
values (?)',[[NIC, first_name, middle_name, last_name, address_no,street,
state,phone_number,email,user_name, password]],function(err,result)
{
if(err) throw err
console.log(result)
});
}
}
module.exports=User
question from:
https://stackoverflow.com/questions/65850229/return-result-of-the-sql-query-in-node-js 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…