TypeError: Cannot read property 'data' of undefined


I’m getting this error :


Can you write your code where you got that error?


@gentlemanoi Actually I’m getting errors in two files, main.js and vendor.js . Both files contains too much long codes.
You can check it here -

main.js - https://drive.google.com/open?id=1HkKcDIyO9oLMUmakyNEPCEsG5xi7lo18
vendor.js - https://drive.google.com/open?id=1X2Yyz08Qx8bLfqxSf1-ovAT_R3-kwmqf

My error -

Runtime Error
Cannot read property ‘data’ of undefined


TypeError: Cannot read property ‘data’ of undefined
at SafeSubscriber._next (http://localhost:8100/build/main.js:1196:31)
at SafeSubscriber.__tryOrUnsub (http://localhost:8100/build/vendor.js:20850:16)
at SafeSubscriber.next (http://localhost:8100/build/vendor.js:20797:22)
at Subscriber._next (http://localhost:8100/build/vendor.js:20737:26)
at Subscriber.next (http://localhost:8100/build/vendor.js:20701:18)
at MapSubscriber._next (http://localhost:8100/build/vendor.js:46324:26)
at MapSubscriber.Subscriber.next (http://localhost:8100/build/vendor.js:20701:18)
at XMLHttpRequest.onLoad (http://localhost:8100/build/vendor.js:26019:38)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660)
at Object.onInvokeTask (http://localhost:8100/build/vendor.js:5425:33)


DId you include

import { HttpClientModule } from '@angular/common/http';

and then add to your imports in the app.module.ts file?

imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, HttpClientModule],


@ChrisGriiffith Yes these are added in app.module.ts file


you are trying to access a variable ‘data’ which has not yet been initialized…

it would be much helpful to see the code which throws the error


@alexmigwi here are the files that showing errors -
main.js - https://drive.google.com/open?id=1HkKcDIyO9oLMUmakyNEPCEsG5xi7lo18
vendor.js - https://drive.google.com/open?id=1X2Yyz08Qx8bLfqxSf1-ovAT_R3-kwmqf

In the above comment I’ve mentioned the exact error message, please check once.


Not many may read through the long lines of code to find the culprit… From what I see you are having an Ionic Wordpress Woocommerce setup here…
My wild guess is that you may have the error coming from an observable subscribed to or promise… taking hint from the variable ‘data’ mentioned in the error.