Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48980

Need help for this error i use Ionic 5 angular.. below the code and the error i got

$
0
0

This code is in Intro.guard.ts

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;

}

}

}

This is my package.json

{

“name”: “WBGS”,

“version”: “0.0.1”,

“author”: “Ionic Framework”,

“homepage”: “https://ionicframework.com/”,

“scripts”: {

"ng": "ng",

"start": "ng serve",

"build": "ng build",

"test": "ng test",

"lint": "ng lint",

"e2e": "ng e2e"

},

“private”: true,

“dependencies”: {

"@angular/common": "~12.1.1",

"@angular/core": "~12.1.1",

"@angular/fire": "^7.2.0",

"@angular/forms": "~12.1.1",

"@angular/platform-browser": "~12.1.1",

"@angular/platform-browser-dynamic": "~12.1.1",

"@angular/router": "~12.1.1",

"@capacitor/app": "1.0.6",

"@capacitor/core": "^3.0.0-rc.4",

"@capacitor/filesystem": "^1.0.6",

"@capacitor/haptics": "1.1.3",

"@capacitor/keyboard": "1.1.3",

"@capacitor/status-bar": "1.0.6",

"@ionic-native/core": "^5.36.0",

"@ionic-native/splash-screen": "^4.20.0",

"@ionic-native/status-bar": "^5.36.0",

"@ionic/angular": "^5.5.2",

"@ionic/storage": "^3.0.6",

"@ionic/storage-angular": "^3.0.6",

"@swimlane/ngx-datatable": "^20.0.0",

"bootstrap": "^5.1.3",

"firebase": "^9.4.0",

"rxfire": "^6.0.0",

"rxjs": "~6.6.0",

"sass": "^1.44.0",

"tslib": "^2.2.0",

"zone.js": "~0.11.4"

},

“devDependencies”: {

"@angular-devkit/build-angular": "~12.1.1",

"@angular-eslint/builder": "~12.0.0",

"@angular-eslint/eslint-plugin": "~12.0.0",

"@angular-eslint/eslint-plugin-template": "~12.0.0",

"@angular-eslint/template-parser": "~12.0.0",

"@angular/cli": "~12.1.1",

"@angular/compiler": "~12.1.1",

"@angular/compiler-cli": "~12.1.1",

"@angular/language-service": "~12.0.1",

"@capacitor/cli": "^3.0.0-rc.4",

"@ionic/angular-toolkit": "^4.0.0",

"@ionic/app-scripts": "^3.2.4",

"@types/jasmine": "~3.6.0",

"@types/jasminewd2": "~2.0.3",

"@types/node": "^12.11.1",

"@typescript-eslint/eslint-plugin": "4.16.1",

"@typescript-eslint/parser": "4.16.1",

"eslint": "^7.6.0",

"eslint-plugin-import": "2.22.1",

"eslint-plugin-jsdoc": "30.7.6",

"eslint-plugin-prefer-arrow": "1.2.2",

"jasmine-core": "~3.8.0",

"jasmine-spec-reporter": "~5.0.0",

"karma": "~6.3.2",

"karma-chrome-launcher": "~3.1.0",

"karma-coverage": "~2.0.3",

"karma-coverage-istanbul-reporter": "~3.0.2",

"karma-jasmine": "~4.0.0",

"karma-jasmine-html-reporter": "^1.5.0",

"protractor": "~7.0.0",

"ts-node": "~8.3.0",

"typescript": "~4.2.4"

},

“description”: “An Ionic project”

}

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)

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48980

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>