I'm using the following code to set up a listener for Firebase Database Ref:
export function listenToUserEventsFeed (userId, cb, errorCB) {
database.ref(`proUserEvents/${userId}`).on('value', (snapshot) => {
console.log('SNAPSHOT RECEIVED')
const feed = snapshot.val() || {}
const sortedIds = Object.keys(feed).sort((a, b) => feed[b].createdAtTimeStamp - feed[a].createdAtTimeStamp)
cb({feed, sortedIds})
}, (error) => {
console.log('SNAPSHOT ERROR: ', error)
})
}
But the console.log('SNAPSHOT ERROR: ', error)
never runs if I test using no internet connection. Am I missing something or is there something wrong in my code? I essentially want to pass down the error to the errorCB()
function.