xxxxxxxxxx
// Answer for Node.js, cheerio
// Assuming you are using .each(async (i, el) => {...})
// The thing with .each() is that it fucks up with async functions.
// Incorrect:
$("x").children().each(async (i, el) => {
el = $(el);
// a lot of processing...
});
// Correct:
// Note: Make sure you are in async function:
const X_children = Array.from($("x").children());
for (let X_child of X_children) {
X_child = $(X_child);
// a lot of processing.
};
// Avoid using for (let i = 0; ..) loop since it doesn't care about async.