'Nested Loop sqlite3 query while Insert not working as expected

We have some iterations to store data, The Below code execute as first loop execute 5 times. After Second loop running,It is not running async.

for (let chapter = 1; chapters < 5; chapter++) {
databases.run(sqltitle, function(err) {
//insert db entery
for (let chapter = 1; chapter < 10; chapter++) {
databasesnew.run(sqlchapter, function(err) {
//insert ten times.
}
});
});
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source