firebase.database().ref('feeds').once('value').then((snapshot) => {
let feeds = []
snapshot.forEach((childItem) => {
feeds.push({
key: childItem.key,
id: childItem.val().id_user,
id_user: childItem.val().id_user,
url: childItem.val().url,
date_posted: childItem.val().date_posted,
name: childItem.val().name,
avatar:childItem.val().avatar,
like_count: childItem.val().like_count,
is_liked: childItem.val().is_liked,
//comments: childItem.comments
})
})
答案 0 :(得分:0)
在我看来,您似乎只需要解构iddoFeed对象即可。您的问题尚不清楚,但我认为这是您要尝试做的事情。
let feeds = []
snapshot.forEach((childItem) => {
feeds.push({
key: childItem.key,
id: childItem.val().iddoFeed.id_user,
id_user: childItem.val().iddoFeed.id_user,
url: childItem.val().iddoFeed.url,
date_posted: childItem.val().iddoFeed.date_posted,
name: childItem.val().iddoFeed.name,
avatar:childItem.val().iddoFeed.avatar,
like_count: childItem.val().iddoFeed.like_count,
is_liked: childItem.val().iddoFeed.is_liked,
})
})