I am tring to store the data from the novelcovid api call "api.countries({country:"USA"}).then(console.log)" into the index_data object. I am using the function getData to store the values into the index_data object. The issue I am having is that the index_data object will not update outside of the scope of the getData() function, I want to be able to globally access the new properties assigned to the object. Any ideas on how I can solve this will be much appreciated.
let totalConfirmed; 
                                          
let index_data = {
  totalConfirmedCases: null,
  totalConfirmedDeaths: null,
  totalRecovered: null,
  casesToday: null
};
api.countries({country:"USA"}).then(totalData);
function totalData(result) {
  totalConfirmed = result.cases; 
  getData(index_data, totalConfirmed);  
};
function getData(theObject, tcVar){
  theObject.totalConfirmedCases = tcVar;
}; 
console.log(index_data);
 
    