Getting Error on project on redirect to home page


#1

Hi,
I was wondering if someone could help me out, I’m struggling with an error which I can’t find any trace of on the internet. it’s “_co.auth is undefined” and it is thrown when I setRoot or push to the homepage of my app. Here is the stack trace:

TypeError: _co.auth is undefined
Stack trace:
View_HomePage_0/<@ng:///AppModule/HomePage.ngfactory.js:56:21
debugUpdateDirectives@http://localhost:8100/build/vendor.js:13443:12
checkAndUpdateView@http://localhost:8100/build/vendor.js:12620:5
callViewAction@http://localhost:8100/build/vendor.js:12988:21
execComponentViewsAction@http://localhost:8100/build/vendor.js:12920:13
checkAndUpdateView@http://localhost:8100/build/vendor.js:12626:5
callViewAction@http://localhost:8100/build/vendor.js:12988:21
execEmbeddedViewsAction@http://localhost:8100/build/vendor.js:12946:17
checkAndUpdateView@http://localhost:8100/build/vendor.js:12621:5
callViewAction@http://localhost:8100/build/vendor.js:12988:21
execComponentViewsAction@http://localhost:8100/build/vendor.js:12920:13
checkAndUpdateView@http://localhost:8100/build/vendor.js:12626:5
callViewAction@http://localhost:8100/build/vendor.js:12988:21
execComponentViewsAction@http://localhost:8100/build/vendor.js:12920:13
checkAndUpdateView@http://localhost:8100/build/vendor.js:12626:5
callViewAction@http://localhost:8100/build/vendor.js:12988:21
execEmbeddedViewsAction@http://localhost:8100/build/vendor.js:12946:17
checkAndUpdateView@http://localhost:8100/build/vendor.js:12621:5
callViewAction@http://localhost:8100/build/vendor.js:12988:21
execComponentViewsAction@http://localhost:8100/build/vendor.js:12920:13
checkAndUpdateView@http://localhost:8100/build/vendor.js:12626:5
callWithDebugContext@http://localhost:8100/build/vendor.js:13843:39
debugCheckAndUpdateView@http://localhost:8100/build/vendor.js:13383:12
ViewRef_.prototype.detectChanges@http://localhost:8100/build/vendor.js:10546:9
ApplicationRef_.prototype.tick/<@http://localhost:8100/build/vendor.js:5169:58
ApplicationRef_.prototype.tick@http://localhost:8100/build/vendor.js:5169:13
next/<@http://localhost:8100/build/vendor.js:5041:100
M</l</t.prototype.invoke@http://localhost:8100/build/polyfills.js:3:14354
onInvoke@http://localhost:8100/build/vendor.js:4247:24
M</l</t.prototype.invoke@http://localhost:8100/build/polyfills.js:3:14281
M</c</r.prototype.run@http://localhost:8100/build/polyfills.js:3:9504
NgZone.prototype.run@http://localhost:8100/build/vendor.js:4178:54
next@http://localhost:8100/build/vendor.js:5041:70
EventEmitter.prototype.subscribe/schedulerFn<@http://localhost:8100/build/vendor.js:3992:36
SafeSubscriber.prototype.__tryOrUnsub@http://localhost:8100/build/vendor.js:27705:13
SafeSubscriber.prototype.next@http://localhost:8100/build/vendor.js:27652:17
Subscriber.prototype._next@http://localhost:8100/build/vendor.js:27592:9
Subscriber.prototype.next@http://localhost:8100/build/vendor.js:27556:13
Subject.prototype.next@http://localhost:8100/build/vendor.js:46504:17
EventEmitter.prototype.emit@http://localhost:8100/build/vendor.js:3978:54
checkStable@http://localhost:8100/build/vendor.js:4212:13
onLeave@http://localhost:8100/build/vendor.js:4291:5
onInvokeTask@http://localhost:8100/build/vendor.js:4241:17
M</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:14942
M</c</r.prototype.runTask@http://localhost:8100/build/polyfills.js:3:10195
M</h</e.invokeTask@http://localhost:8100/build/polyfills.js:3:16167
e/this.invoke@http://localhost:8100/build/polyfills.js:3:16049
n@http://localhost:8100/build/polyfills.js:2:31385

Here is the function i call it from:

constructor(private toast: ToastController, private fb: FireBaseProvider, public navCtrl: NavController, public navParams: NavParams) {
  }


  createProfile(profile: Profile){
    this.fb.createProfile(profile)
    this.toast.create({
      message: 'Profile information updated',
      duration: 3000
    }).present();
    this.navCtrl.push(HomePage);
  }

and the function at the other end of fb.createProfile is:

profile = {} as Profile;
  user = {} as User;

  constructor(private afAuth: AngularFireAuth, private afDatabase: AngularFireDatabase) {
  }

  createProfile(profile: Profile){

    this.afAuth.authState.take(1).subscribe(auth => {
      this.afDatabase.list(`profile/${auth.uid}`).push(this.profile);
      });
  }

i rellly hope someone can help me out with this because I’m completely stumped!

Thanks in Advance!