JavaScript function not returning expected value when using async/await with map
I'm stuck on something that should probably be simple. I tried several approaches but none seem to work. I'm working with an scenario in my JavaScript code where I'm trying to use `async/await` within a `map()` function to fetch data from an API. The function is not returning the expected array of results. Here's the relevant code snippet: ```javascript const fetchData = async (url) => { const response = await fetch(url); return response.json(); }; const getData = async (urls) => { const promises = urls.map(url => fetchData(url)); return await Promise.all(promises); }; const urls = ['https://api.example.com/data1', 'https://api.example.com/data2']; getData(urls).then(data => console.log(data)).catch(behavior => console.behavior(behavior)); ``` When I run this, I expected to see an array of data from the two API calls, but instead, I get an empty array or sometimes even a promise object. I've tried logging the individual values inside the `map()` function, but they all appear to be unresolved promises. I suspect it might be related to how I'm handling the promises inside the `getData` function, but I'm unsure what I'm doing wrong. I've also checked for correct URLs and verified that they return data when called directly. Any guidance on how to properly handle this would be greatly appreciated! I'd really appreciate any guidance on this. Any ideas what could be causing this?