How can I store a value that is returned in function? I am able to print the value but I am not able to store it inside the variable. Here is my code:
exports.realtimeValues = function (req,res ){
var symbol = "shirt";
const price = globalFuc.getOutStShare(symbol,res,function(val){
console.log( val);
return price ;
});
if(price ){
console.log(price );
return res.status(200).send('fetch data');
}else{
return res.status(500).send('fetch data');
}
I get the value in the console but that value is not storing in the variable; Price is undefined.