Want to add more images from firebase when button clicked
I wrote a function,
onLoadMore() {
if (this.all.length > 1 ) {
const lastLoadedPost = _.last(this.all);
const lastLoadedPostKey = lastLoadedPost.key;
this.loadMoreRef = firebase.database().ref('allposts').startAt(lastLoadedPostKey, lastLoadedPost).limitToFirst(7);
this.loadMoreRef.on('child_added', data => {
if ( data.key === lastLoadedPostKey ) {
return;
} else {
this.all.push({
key: data.key,
data: data.val()
});
}
});
}
}
but when i click button console shows me this error,
Query.startAt failed: second argument was an invalid key = "[object Object]". Firebase keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]").
When a button click click i want add more images but i don't want to repeat existing images