Hello , I am developing an PWA in ionic 2 . Earlier it was working fine … suddenly I started getting error when I try to change anything in the application .
The code is below , I have just added a condition for setting the root page `
export class MyApp {
rootPage:any = HomePage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
let params = new URL(window.location.href);
let id = params.searchParams.get('id') || '';
if(id) {
this.rootPage = OffersPage;
}
});
}
}
please show the line in your code that cause this error. You are calling “call” from something that is undefined, we need to find that right place in your code. I don’t think the error happen in the code you paste here.
i understand that, but the error not come from there.
console.log the “id” and if the root is change to “OffersPage” so the problem is in “OffersPage”;
maybe i am wrong maybe not, cost nothing to check it.
you need to use separation of concern, create provider that will hold your http call.
retrieve data in your page in ionViewDidLoad, the constructor should not be use for complicate stuff, just for simples initializations.
use console.log in home and offer to track down in which page the error occur, and track down the error till find out where exactly your code break.
You can share a git repo with the project, so i could download and run it and try to figure out where it broke.(suggestion)
Thanks for your help and suggestion … I have moved all the complex code inside ionViewDidLoad and it worked without any issue after doing the changes also …
I’ve been seeing something like this too: randomly getting “Cannot read property ‘call’ of undefined”.
Any code change didn’t seem like it would trigger this. And, more tellingly, simply restarting ionic serve fixed the problem. That makes me thing it’s not in the application code, but somewhere deeper.
Hi, I have the same issue in Ionic 3 PWA.
The error happened when i do some action(click or navigate) after app was served
It happened once in a while, not everytime.
I have also deployed the app in firebase host.
This error will sometime show when i open the app.
I suspect this is problem of the service worker.
I have try @manoemerson, but its not work, the error remain, below is my service worker
I’ve found the same. A simple restart works every time. I’ll keep an eye out for it to see if there’s a pattern, but I would definitely recommend just restarting to see if that does the trick.
I’m getting the same errors as above. A seemingly random error appears when navigation through my PWA app.
vendor.js:1 ERROR Error: Uncaught (in promise): TypeError: Cannot read property ‘call’ of undefined
TypeError: Cannot read property ‘call’ of undefined
at e (vendor.js:1)
OR
TypeError: Cannot read property ‘call’ of undefined
at e (vendor.js:1)
So nobody has any idea about why I’m getting these random errors. It only happens when a user does an action, for example: click on a checkbox, click on a tab link, click on a item list.
It really seems like the build is corrupted as reloading sometimes fixes it and I can use the app with no issue.
I believe this issue is related to the browser using cached versions your lazy loaded pages. You can avoid this issue during development by disabling your browser’s cache:
I am having the same Issue for days now. Occurs with ionic serve as well as in production running ionic build --prod or nom run ionic:build --prod.
After rebuilding the errors occur in different patterns, but always very randomly upon clicking a button that switches a page.
I assume it has something to do with Lazy Loading, but I have no idea how to get a hold of it…