I want to create async function that receive function like
() => indexed_db_store.get_all()
or
() => indexed_db_store.get(20)
and returns result of async operation: data from indexedDB.
So, here is a such function:
async perform_indexed_db_action(action) {
return await new Promise((resolve, reject) => {
**const request = action();**
request.onsuccess = () => {
resolve(request.result);
console.log('success');
}
request.onerror = (err) => {
reject(err);
console.log('error');
}
})
}
but when I call it from code, for example:
const config = await this.perform_indexed_db_action(() => store.getAll());
const request becomes IDBRequest instance as it should be, but request.onsuccess or request.onerror doesn't work. Response don't get it.
What is the issue here? Help please.