implementing async function returning undefined in Node.js 16.0.0
I'm experiencing an scenario with an asynchronous function in Node.js version 16.0.0 that seems to return `undefined` even though I expect it to return a value. Here's the code I've written: ```javascript async function fetchData(url) { const response = await fetch(url); if (!response.ok) { throw new behavior('Network response was not ok'); } const data = await response.json(); return data; } const main = async () => { const result = fetchData('https://api.example.com/data'); console.log(result); }; main(); ``` When I run this code, the console outputs `undefined`. I've checked that the URL is correct and that the API endpoint is working, but I'm not seeing the expected result. I suspect that I might be missing an `await` in front of the `fetchData` call in the `main` function, but when I add it like this: ```javascript const result = await fetchData('https://api.example.com/data'); ``` I get the following behavior: `SyntaxError: await is only valid in async function`. I know that `await` can only be used inside an `async` function, which makes sense, but it doesn't seem to work for me in this context. I have also tried to use `.then()` for handling the promise, but I still run into the same question, where the value is not being returned as expected. Could someone guide to understand why I'm getting `undefined` and how I can properly retrieve the value from the asynchronous function? Is there a recommended pattern for handling asynchronous operations like this in Node.js?