I try to access the data that is inside a promise from outside the promise.
If I use the code below for console.log(result)
, the data appears.
dataModel.lastIndex(name, function(err, result){ console.log(result) });
But, when I try to use return and a variable to save the return results, I can't find the results.
let data1 = dataModel.lastIndex(name, function(err, result){ return result});
console.log(data1); // doesn't work
How do I return the results that have been promised so that I can use them outside of promise?
Because I have tried to find some of the same questions, but have not been able to solve my problem.
I beg for help.
Thank you in advance.