How to return indexedDB query result out of event handler?
问题 I have to return query result from indexedDB, but the result is only available in onsuccess event handler. 1 function listPeople(){ ... 4 var open = indexedDB.open("AccordionDatabase",1), 5 res; 6 7 open.onsuccess = function(){ 8 var db = open.result; 9 var transaction = db.transaction("PeopleStore", "readwrite"); 10 var store = transaction.objectStore("PeopleStore"); 11 var request = store.getAll(); 12 request.onsuccess = function(event){ 13 res = event.target.result; 14 console.log(res); 15