I'm a new to coding and currently struggling with promises and await/async. I'm trying to access the data coming from the currPrice
variable outside of the function scope. Can someone point me in the right direction?
var price
const getPrice = async () => {
//Get the curent market price
var marketSymobl = checkOrders[i].symbol.split(" - ")[0].toUpperCase()
console.log(checkOrders[i].symbol)
finnhubClient.quote(marketSymobl, (error, data, response) => {
const currPrice = data.c
console.log(currPrice);
return currPrice
});
}
//const x = getPrice().then(price => (console.log(x)))
price = await getPrice()
console.log(price);