Matching Error State with createAsync

When using createResource one has access to resource.error to handle the case when we get an error from our remote calls.
<Switch>
<Match when={user.error}>
<span>Error: {user.error}</span>
</Match>
<Match when={user()}>
<div>{JSON.stringify(user())}</div>
</Match>
</Switch>
<Switch>
<Match when={user.error}>
<span>Error: {user.error}</span>
</Match>
<Match when={user()}>
<div>{JSON.stringify(user())}</div>
</Match>
</Switch>
How would I go about doing something similar when using createAsync and query? If it's in a preload function of the router and fails is the only recourse to have the entire page fall back to an ErrorBoundry?
1 Reply
Brendonovich
Brendonovich2mo ago
Error boundary would be the recommended approach. imo if it fails in a preload function don't do anything, wait until the component is actually loaded to handle the error
Want results from more Discord servers?
Add your server