I just start a indexedDB for my react PWA. And i get this error.
Uncaught DOMException: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found. at request.onsuccess
line is: const transaction = db.transaction("storeName", "readwrite");
and the func i did:
const handleSubmit = (event) => {
event.preventDefault();
const request = window.indexedDB.open("NewApp", 1);
request.onsuccess = () => {
if (nameArea && enterDate) {
const db = request.result;
const transaction = db.transaction(["apps"], "readwrite");
const store = transaction.objectStore("apps");
store.put({ nameArea, enterDate: Date.now() });
const query = store.get(1);
query.onsuccess = function () {
console.log("next info", query.result);
};
transaction.oncomplete = function () {
/db.close();
};
};
request.onerror = function (event) {
console.error("An error occurred with IndexedDB");
console.error(event);
};
}
};
That problem is in only new opened browser, when i debug it records are adding but not only empty string.
I just changed the version and recreate db. So now it's working.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.