简体   繁体   中英

Error showing data from firebase to ionic

I want to display data from this console.log and i have a error.

在此处输入图片说明

Error is: Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.

This is part of the code:

this.dbFire.database.ref('found').orderByChild('author_email')
            .equalTo(this.email)
            .once('value')
            .then(snapshot => snapshot.val())
            .then((data) => {
                this.getUserPosts = data;

                console.log(this.getUserPosts);
            });

Thank you !

// declare variable as empty array
getUserPosts: any[] = [];

this.dbFire.database.ref('found').orderByChild('author_email').equalTo(this.email).once('value')
    .then(snapshot => snapshot.val())
    .then((data) => {
        // push data
        this.getUserPosts.push(data);
        console.log(this.getUserPosts);
    });

<li * ngFor="let user of getUserPosts" >
    {{ user.author_email}}
</li>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM