I am trying to automate an xls file download and import in Mongo process. Every so often I think my file download is not working properly and I get erorrs from Xlsx [TypeError: Cannot read property '3' of undefined], but I am unable to find a way to catch these errors with code - can you advise?
function xls2Json(fname) {
return new Promise( (resolve, reject) => {
var wbook = XLSX.readFile(fname+'.xls');
var worksheet = wbook.Sheets[SHEET_NAME];
let json = XLSX.utils.sheet_to_json(worksheet, {header:headers, range:1});
resolve(json);
});
}
I am trying to automate an xls file download and import in Mongo process. Every so often I think my file download is not working properly and I get erorrs from Xlsx
[TypeError: Cannot read property '3' of undefined], but I am unable to find a way to catch these errors with code - can you advise?