In my angular app, i have a function that basically returns an object.
private getTypeAndLocation() {
const type = sessionStorage.getItem('type');
const location = sessionStorage.getItem('location');
return {type, location};
}
Now I am calling this function from ngOnint
like this:
({this.MyObjectVariable.type, this.MyObjectVariable.location} = this.getWorkClearanceTypeAndLocation());
But unfortunately its not working. I am getting this error:
Property 'this' does not exist on type '{ type: string | null; location: string | null; }'.
It could be possible that getTypeAndLocation will return undefined if the type and location are not set.
In that case, how can i do the object Destructuring?