I have below function
const initSync = () => {
return localDB
.sync(remoteDB, {
live: true,
retry: true
})
.on('change', function(change) {
if (change.direction === 'pull') {
console.log(change.change.docs) //this worked
return change.change.docs
}
})
}
I want to call it somewhere
I do const result = await initSync()
, but in result
I get nothing, I feel strange, should I wrap it with a promise for above function?