I am new to web dev so please forgive.
I make simple api call
const getWorldTotal = async () => {
const response = await fetch('https://cors-anywhere.herokuapp.com/https://health-api.com/api/v1/covid-19/total');
const worldTotal = await response.json();
alert(worldTotal.total_confirmed)
document.getElementById('total') = worldTotal.total_confirmed
};
getWorldTotal()
Here is my html that i am trying to update
<div class="card text-white bg-secondary mb-3" id="total" style="max-width: 20rem;">
<div class="card-header">Header</div>
<div class="card-body">
<h4 class="card-title" id="total"></h4>
</div>
</div>
I get the following error
index.html:80 Uncaught (in promise) ReferenceError: Invalid left-hand side in assignment at getWorldTotal
My question is what did i do wrong? Also is this the best way to update HTML when making api calls ?