I'm having trouble understanding the difference between the 2 approaches taken.
I have a certain Promise.All which works as expected, after that, a then function is used to extract data from the responses. I can't figure out why if I use the forEach approach i get printed the data, but if I use the map approach i get return Promises.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script>
Promise.all(
["koop4", "gVenturi", "aledocdonnini" ].map( user => fetch( 'https://api.github.com/users/'+user+'/repos', { method: 'GET'}) )
).then( res => {
// this works properly
const data = [];
res.forEach( async r => {
data.push(await r.json());
});
return data;
// this return promises
/* return res.map( async r => await r.json() n)*/
}).then(console.log)
</script>
</head>
<body>
</body>
</html>