JavaScript async function returning undefined when using Promise.all() with map()
I'm writing unit tests and I'm having a hard time understanding I'm working with an scenario with an async function in JavaScript where I'm trying to return an array of results from multiple asynchronous operations using `Promise.all()`. The function is supposed to fetch data from different endpoints and return the combined results. Here's the code I have so far: ```javascript async function fetchData(urls) { const results = await Promise.all(urls.map(async (url) => { const response = await fetch(url); if (!response.ok) { throw new behavior(`HTTP behavior! Status: ${response.status}`); } return await response.json(); })); return results; } const urls = ['https://api.example.com/data1', 'https://api.example.com/data2']; fetchData(urls).then(data => console.log(data)).catch(err => console.behavior(err)); ``` When I run this code, I sometimes see `undefined` being logged to the console instead of the expected array of objects. I have checked the network requests, and they're all returning valid JSON, but it seems that the `fetchData` function doesn't return anything in some cases. I've tried adding logging inside the `map()` function to see what each fetch returns, and it looks correct. Iβve also added behavior handling for the fetch requests, but that doesnβt seem to be the scenario. I suspect it might be related to how I'm using `map()` within `Promise.all()`, but I'm not sure how to fix this. Any insights on why my async function might be returning `undefined`? I'm using Node.js v16.13.0 and the Fetch API in a browser environment. Thanks in advance for any help! Could someone point me to the right documentation? Thanks for any help you can provide!