Currently running Chrome Version 57.0.2987.110 (64-bit) on MacOS/OSX 12.3 Sierra,
I have recently set up a service worker, but I am relatively new to this.
Now I am working on integrating an IndexedDB to store data.
The service worker successfully fetches data from a local web server in HTTP and retrieves it in JSON format.
The data structure is as follows:
[{"id":"1", "...":"...", ...},
{"id":"2", "...":"...", ...},
{"id":"3", "...":"...", ...},
...
{"id":"n", "...":"...", ...}]
After adding the data to the IndexedDB, the onsuccess callback gets triggered, but the data does not appear in the Chrome dev tools!
Below is the service worker script:
// Service worker script here
// Code not provided for brevity
And here is the accompanying HTML file:
<!DOCTYPE html>
<html>
<head>
<title>My service worker app</title>
</head>
<body>
// HTML content
</body>
</html>
Any insights on what could be going wrong?
Edit 1:
I made a modification to the update mechanism in the HTML file to request data from the service worker:
// Update mechanism script
// Code not provided for brevity
Also, added a line:
// Additional line of code
// Code not provided for brevity
At the beginning of the data lookup section which lists all IndexedDBs in Chrome.
After executing the code for data lookup, all previously created databases were listed!
Then, I proceeded to list all ObjectStores in these databases.
After examining the object stores, it seemed that the entries were present as expected, except for one specific case...
Edit 2:
The issue with 'db2' was resolved by refreshing the data in the database.
Edit 3:
The solution turned out to be as simple as closing and reopening the dev tools, following @wOxxOm's suggestion.