Problem
I use async setup()
in Vue.js 3, but I got my HTML content to disappear. My component template did not insert to HTML, but when I remove the async and await prefix, my HTML content comes back. How can I fix this?
async setup () {
const data = ref(null)
try {
const res = await fetch('api')
data.value = res.json()
}
catch (e) {
console.error(e)
}
return {
data
}
}
I've tried
- I checked fetch, and it returned the correct response
- I've tried
<Suspense>
tag, but still the same problem