I am new to Javascript and Nodejs so this question might sound very basic.I am trying to fetch the value returned from promise elsewhere. I tried using getter method and also tried using global variable and assigning it to the local variable to fetch it but I still have difficulties.
var initCounter = 0;
function sql_count() {
sql_connection.User.count().then(function (count) {
if(count) {
initCounter= count; //-> I would like to get the value of count.
console.log(initCounter);
return initCounter;
}
});
};