0

I have questions: Is syntax of code below valid? can i use promises to append onsuccess events?

db.transaction(['store'],'readwrite').objectStore('store').get(1).onsuccess = new Promise(async function(resolve){ 
    resolve(e.target.result); 
}
redevil
  • 155
  • 7
  • 1
    No, it’s almost certainly incorrect. `onsuccess` expects a function, not a Promise. This can be a function that calls `resolve` from an existing Promise. – Sebastian Simon Nov 14 '22 at 10:26

0 Answers0