NuxtN
Nuxt9mo ago
15 replies
clownshark5503

useFetch return null sometimes

Hello! I have a call to my backend

const headers = useRequestHeaders(['authorization'])
const { data, status, error } = await useFetch('https://localhost:7225/mybackend', { headers,lazy: false, server:false})

 onMounted(() => {
      console.log("in onMounted")
      console.log("status: ", status.value)
      console.log("Error:", error.value)
      console.log("data: ", data.value)
      
      
    })

And sometimes when I refresh the page it tells me data.value is null. When this happens Status is Pending and error is also null.

I have no idea whats going on and could really use some guidance.
Was this page helpful?