I have an onload function from an XMLHTTPRequest function which is configured like so.
CreateExcel()
{
let url = this.GetDownloadURL();
var req = new XMLHttpRequest();
req.open("GET", url, true);
req.responseType = "arraybuffer";
req.onload = function(e)
{
var data = new Uint8Array(req.response);
var workbook = XLSX.read(data, {type:"array"});
var worksheetName = workbook.SheetNames[0];
var workSheet: XLSX.WorkSheet = workbook.Sheets[worksheetName];
let s3Sheet = (XLSX.utils.sheet_to_json(workSheet, {header: 1}));
console.log(s3Sheet)
}
req.send();
}
I understand that req.onload is asynchronous, but is there a way for me to take that s3Sheet variable and access it within the CreateExcel function after the req.send() is complete?