Skip to content

Instantly share code, notes, and snippets.

@ralfting
Last active September 17, 2019 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralfting/5701e0184c391a210389e10e62a66a2e to your computer and use it in GitHub Desktop.
Save ralfting/5701e0184c391a210389e10e62a66a2e to your computer and use it in GitHub Desktop.
const arr = [1,2,3,4];
let newArr = [];
const fetchMock = (item) =>
new Promise(resolve => setTimeout(() => resolve(item), 500));
function someFunc() {
[1,2,3,4].forEach(async (item) => {
const result = await fetchMock(item);
newArr.push(result);
console.log(newArr);
});
console.log('me first');
}
someFunc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment