function searchData(){
NodeInfo.find({}, function(err, res){
if(err) {
console.log("Error:" + err);
}
console.log(JSON.stringify(res,null,2)); //1
return res;
})
}
let a = searchData();
console.log(a); //2
Why does print 1 show complete data and print 2 to tell undefined, how to save the found data to an array?