我有一个应用程序,我从Firebase返回值,现在某些值可能为null,而当这些值为null时,我希望能够跳过此值并继续进行下一个操作。到目前为止,这是我的代码
firebase
.ref('geo')
.once('value')
.then(async snapshot => {
var firebaseChampions = snapshot.val();
//Filters and returns only champions present in the DB and on firebase
console.log(firebaseChampions);
var currentChampions = champions.filter(
champion => {!!firebaseChampions[champion.id]}
);
...
使用这样的代码,我的应用程序崩溃,因为值为空,即article4
如何跳过此步骤并继续操作,以使应用不会崩溃
"article_list" : {
"article1" : {
"published" : 1459296000000
},
"article2" : {
"draft" : 1333065600000
},
"article3" : {
"published" : 1461974400000
}
}