I do not understand why the query variable has a value inside async function that changes when returned and declared in the global environment. I want to return the value from my database to a global variable outside of the async function. What is the logically reason this happens. How do I extract the integer value from the Promise {1}.
async function glob(){
var result = await knex.raw('select max(glob) from or');
let query = await result.rows[0].max ;
console.log(query);
return query ;
}
let go = glob();
setTimeout(()=>{console.log(go)},1000);
setTimeout(()=>{console.log(go == 1)},1000);
1
Promise { 1 }
false