This bug is so common it deserves its own unit:
const data = fetchData() // Missing await! console.log(data.length) // TypeError: undefined
fetchData returns a Promise, not the data. Without await, data is the Promise object. Adding await fixes it:
const data = await fetchData()
When you see unexpected undefined values, check for missing awaits first.