2

Ich baue eine Ionic 2 + Firebase-Anwendung, aber jetzt bin ich für eine Weile fest. Ich kann das Problem damit nicht feststellen.Ionic 2 + Firebase - Lade Userdata dauert 30-60 Sekunden

Ich lade die Daten von Firebase. Auf der Konsole kann ich sehen, dass es gut funktioniert (Ladezeit max. 1 Sekunde).

Es dauert jedoch bis zu 60 Sekunden, bis die Daten auf der Benutzeroberfläche der App angezeigt werden.

Suchen Sie die Konsolenausgabe mit dem Benutzerdaten here.

Code:

HTML:

<ion-content padding> 
    <ion-list> 
     <ion-item *ngFor="let item of items"> 
      <h2>{{item?.birthDate}}</h2> 
      <p>Ticket: <strong>{{item?.username}}</strong></p> 
      <p>Date: <strong>{{item?.email}}</strong></p> 
     </ion-item> 
    </ion-list> 
</ion-content> 

profile.ts:

ionViewDidEnter() { 
    this.authData.getUserProfile().on('value', snapshot => { 
     let rawList = []; 
     rawList.push({ 
     birthDate: snapshot.val().birthDate, 
     email: snapshot.val().email, 
     gender: snapshot.val().gender, 
     password: snapshot.val().password, 
     phone: snapshot.val().phone, 
     username: snapshot.val().username, 
     weight: snapshot.val().weight 
     }); 
     this.items = rawList; 
     console.log(this.items); 
     console.log(rawList); 
    }); 

    } 

Auth Service:

public userProfileData: any; 
    public currentUser: any; 

    constructor(public af: AngularFire) { 
    af.auth.subscribe(user => { 
     if (user) { 
     this.currentUser = firebase.auth().currentUser.uid; 
     this.fireAuth = user.auth; 
     this.userProfileData = firebase.database().ref(`users/${this.currentUser}/`); 
     } 
    }); 
    } 
    getUserProfile(): any { 
    return this.userProfileData; 
    } 

Antwort