mykola
handling (http) errors with createResource
I don't understand how to get hold of the error when using the tutorial examples of fetching REST data. The error is always either empty, or not callable to me ("solid-js": "^1.8.11").
If I take the example from the documentation here and make it work. I shows the fetched data OK, but doesn't handle http404's. OK, I modify the
fetchUser
function to throw on non-ok:
the rendering gets broken because the user.error()
isn't a function š¤
When I replace user.error()
with the typeOf
and JSON.stringify
, they show an empty object {}
.
ā What do I do wrong, and how to get the resource errors reported properly?
I tried Promised.reject(new Error(...))
and axios.get
with no change in behavior.
Playground example: https://playground.solidjs.com/anonymous/3b5dbdc3-c242-4d24-8468-f7b5c98509ed9 replies