You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've spent a bit of time researching error handling with useAsyncData and I've found very little on this subject. In my app I have a page which views an article list. When a user clicks an article it navigates to a single article view using the article id. I use the following code to retrieve the article:
I would expect the error object to contain the same 404. and perhaps a message Not Found. Why would I receive a 500?
Also, how should I manage an error in the template? Should I use a v-if to hide the content area or perform a redirect to articles? If I use a v-if should it be conditional on a property of the error object or on the data itself?
The text was updated successfully, but these errors were encountered:
Same question. I tried wrapping findOne with try ... catch, but failed to catch the raw error of strapi.
So I found out the strapiClient source code, it does not throw strapi raw error but passes the error to strapi:error hook.
We can only get the raw error in strapi:error hook, maybe we should detect if data is null inside page then display 404, for other error then toast message in hook.
I've spent a bit of time researching error handling with
useAsyncData
and I've found very little on this subject. In my app I have a page which views an article list. When a user clicks an article it navigates to a single article view using the article id. I use the following code to retrieve the article:If I try to retrieve an invalid article using the API direct with
http://localhost:1337/api/articles/2
I receive a404
and a response:But when I inspect the
error
object from the above code usingconsole.log('error:', JSON.stringify(error))
I get in response:I would expect the error object to contain the same
404
. and perhaps a messageNot Found
. Why would I receive a 500?Also, how should I manage an error in the template? Should I use a
v-if
to hide the content area or perform a redirect to articles? If I use av-if
should it be conditional on a property of the error object or on the data itself?The text was updated successfully, but these errors were encountered: