There are 6 keys in the database and I confirmed it by checking it in the browser console.
The following code only loops 3 times and after the condition becomes false, it stops.
localforage.iterate(function (value, key, iterationNumber) {
console.log(key);
if (key != lastReminderIdKey) {
//console.log(value);
}
}).then(function (value) {
console.log('Iteration has completed');
}).catch(function (err) {
console.log(err);
});
This code was working fine when it was inside the HTML file. Then I moved it to a JS file and the iteration/loop works only partially now. When I move it back to the HTML file, it works alright.
The keys in DB are 1, 2, lastReminderKey, 3, 4, 5. In console log, when run from the JS file, it prints:
1
2
lastReminderKey
Iteration has completed
What could be the reason for this behaviour?
from localForage iterate does not work from JS file
No comments:
Post a Comment