N
Nuxtβ€’6mo ago
Stefan

Response Body in Error with useFetch

πŸ‘‹, I get the following error in an API request (see attachment). Is there a way to get the response body using useFetch? I have tried using interceptors but no luck so far. The status code and status message are fine, but the response body is nowhere to be found.
No description
2 Replies
Ragura
Raguraβ€’6mo ago
You can get both the body and error by destructuring the return value of the useFetch promise.
const { data, error } = await useFetch('myurl')
const { data, error } = await useFetch('myurl')
Stefan
StefanOPβ€’6mo ago
Thank you! I solved it and it was one of these face palm moments 😳 I simply forgot to add it to my error object (server error > fetch error in my store > error display on page)
Want results from more Discord servers?
Add your server