This is my code:
var itemData = [];
JSON.parse(row2['items']).forEach(async(item) => {
sql = `SELECT * FROM \`items\` WHERE \`id\` = '${item}'`;
db.get(sql, [], (err, row3) => {
itemData.push(row3);
console.log(itemData);
console.log(1);
});
console.log(itemData);
console.log(2);
});
console.log(itemData);
console.log(3);
And it outputs this (with DB response removed):
[]
2
[]
3
[
{
//row data was here
}
]
1
I tried awaiting the forEach and the db.get, but nothing changed