How to access the results variable outside of the function.
con.query(
"SELECT * FROM table WHERE particulars = 'data'",
(error, results) => {
if (error) {
return console.error(error.message);
}
console.log(results);
}
);
Console.log is working fine inside the function but when I return the results variable to use it outside the function I get an undefined variable. I know I should use something like an async function but I can't figure out how to use it in this case.
Thank you in advance.