I've the following code which works, I currently configure eslint and got following error
1. ESLint: iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations. (no-restricted-syntax)
2. ESLint: Unexpected `await` inside a loop. (no-await-in-loop)
The idea of the code is following:
loop on global accounts which contain list of accounts (first for)
prepare request for eu region
prepare request for us region
run async request to get the users from EU
loop on the value and if find url return 6 - 7 same as 4-5 but for US region
async function acount(global) { // here i got the first eslint error iterators/generators for (const account of global) { // create http request for getting the users - region EU let usersEUReq = getUsers(account.guid, region.1); // create http request for getting the users region US let usersUSReq = getUsers(account.guid, region.2); const usersEU = await axios(usersEUReq); // here I got the response from the promise and should loop on it got get URL for (const sub of usersEU.data) { if (sub.url) { return sub.url } } const usersUS = await axios(usersUSBReq); for (const sub of usersUS.sub) { if (sub.url) { return sub.url } } }
btw, I cannot use Promise.all
or race
as I need the code run for Eu and then US