As I work on developing an app using vue.js, I am currently facing a minor issue.
async fetchCovidDataByDay(){
const res = await fetch(`https://api.covid19api.com/live/country/${this.name}/status/confirmed`);
const data = await res.json();
this.arrConfirmed= [];
this.arrDeaths = [];
this.arrRecovered = [];
this.arrActive = [];
data.forEach(item =>{
const date = moment(item.Date).format('MMMM Do YYYY');
const {
Confirmed,
Deaths,
Recovered,
Active
} = item;
this.arrConfirmed.push({date, total: Confirmed})
this.arrDeaths.push({date, total: Deaths})
this.arrRecovered.push({date, total: Recovered})
this.arrActive.push({date, total: Active})
})
return data;
},
Hence, I aim to calculate the daily increase in confirmed cases by subtracting Confirmed[i] from Confirmed[i-1] :)