Я работаю в node.js и пытаюсь получить данные из API с использованием Async/await. Вот упрощенная версия моего кода: < /p>
async function fetchData() {
const res = await fetch('https://api.example.com/data');
const data = await res.json();
return data;
}
const result = fetchData();
console.log(result); // Promise { }
---
### **What did you try and what were you expecting?**
```markdown
- I tried using await in different places.
- I tried wrapping the call in another async function.
- I expected `console.log(result)` to print the actual data from the API, not a Promise.
How can I fix this to get the actual result?
Подробнее здесь: https://stackoverflow.com/questions/796 ... in-node-js