I'm trying to get api data using axios (This is working) and rendering at the same time when I press the anchor tag.
Unfortunately, i have to click it two times, once get the api data (I can see it in console), and I have to pressed again to render the data. I can not figure out how to fix it.
const getCrypto = async () => {
try {
const response = await axios.get(url)
if(response){
crypto = response.data;
console.log(crypto)
};
} catch (err){
console.log(err)
}
}
app.get('/', function (req,res){
money = GBP;
getCrypto();
res.render('index.ejs', {cryptos:crypto, money:money});
})