below is the code
import { Injectable } from ‘@angular/core’;
import { CanLoad, Route, Router, UrlSegment, UrlTree } from ‘@angular/router’;
import { Observable } from ‘rxjs’;
export const INTRO_KEY =‘intro-seen’;
import { Plugins } from ‘@capacitor/core’;
const {Storage} = Plugins;
@Injectable({
providedIn: ‘root’
})
export class IntroGuard implements CanLoad {
constructor(private router: Router){}
async canLoad(): Promise{
const hasSeenIntro = await Storage.get({ key: INTRO_KEY});
if(hasSeenIntro && (hasSeenIntro.value === 'true')){
return true;
}
else{
this.router.navigateByUrl('/intro',{replaceUrl:true});
return true;
}
}
}
and this is the error i got
core.js:6479 ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading ‘get’)
TypeError: Cannot read properties of undefined (reading ‘get’)
at IntroGuard. (main.js:250)
at Generator.next ()
at vendor.js:117087
at new ZoneAwarePromise (polyfills.js:11276)
at __awaiter (vendor.js:117083)
at IntroGuard.canLoad (main.js:249)
at vendor.js:88045
at Array.map ()
at ApplyRedirects.runCanLoadGuards (vendor.js:88041)
at ApplyRedirects.getChildConfig (vendor.js:88023)
at resolvePromise (polyfills.js:11191)
at resolvePromise (polyfills.js:11145)
at polyfills.js:11257
at ZoneDelegate.invokeTask (polyfills.js:10370)
at Object.onInvokeTask (vendor.js:70398)
at ZoneDelegate.invokeTask (polyfills.js:10369)
at Zone.runTask (polyfills.js:10141)
at drainMicroTaskQueue (polyfills.js:10556)