My code is intended to read and upload a JSON file (ARM template), but I am encountering an issue where this.updateObj appears as undefined in the console.log. Below is my code:
onChange(fileList: FileList): void {
var file = fileList[0];
var fileReader = new FileReader();
var newFile = {};
fileReader.readAsText(file, 'UTF-8');
fileReader.onload = () => {
newFile = fileReader.result as object;
this.updateObj = cloneDeep(newFile);
};
console.log('updateObj', this.updateObj);
}
Any insight or suggestions on how to resolve this problem are greatly appreciated.