I have a promise that resolves a variable this.data
in a Read Excel Service
as shown below,
parseExcel(excelFile): Promise<any>
{
/* wire up file reader */
const target: DataTransfer = <DataTransfer>(excelFile.target);
if (target.files.length !== 1) throw new Error('Cannot use multiple files');
const reader: FileReader = new FileReader();
return new Promise((resolve, reject) => {
reader.onload = (e: any) =>
{
/* read workbook */
const bstr: string = e.target.result;
const wb: XLSX.WorkBook = XLSX.read(bstr, { type: 'binary' });
/* grab first sheet */
const wsname: string = wb.SheetNames[0];
const ws: XLSX.WorkSheet = wb.Sheets[wsname];
/* save data */
this.data = <AOA>(XLSX.utils.sheet_to_json(ws, { header: 1 }));
console.log("BOM PARSE SERVICE LOG: " , this.data)
resolve(this.data);
};
reader.readAsBinaryString(target.files[0]);
})
}
I am now trying to access the resolved array here
async ReadExcel(event)
{
return new Promise<Object>((resolve, reject) =>
{
var excelContents = this.parser.parseExcel(event).then(function(value)
{
return value
}
console.log("New Quote Component Log: ", excelContents)
//need var excelContents to only contain the array and not contain the value of the promise object
}
)}
}
the log statement in the latter function brings me back this...
Is there a way that I can have the variable excelContents
only take on the value of the array rather than the entire value of the promise?