Reputation: 2648
I'm trying out CycleJS with xstream and I can't find a way to both rescue an error (e.g. 422) and get the JSON response from the HTTP driver.
To rescue from an error, I'm using xstream's replaceError
which seems to work like this:
sources.HTTP
.select('hello')
.map((response$) =>
// No response$.body or response$.error, just response$.request.
response$.replaceError(() => xs.of(errorObject))
).flatten()
However, the API returns an error message that I would like to display to the user, and it is lost if replaced with a default object. The only property on the response$
that's set is the actual request data.
Versions:
"@cycle/dom": "^12.2.5"
"@cycle/http": "^11.0.1"
"@cycle/xstream-run": "^3.1.0"
"xstream": "^6.4.0"
Any ideas are appreciated!
Upvotes: 2
Views: 251
Reputation: 13994
Try to catch the error object err
in the argument for replaceError
(you weren't using it):
response$.replaceError(err => /* use err here */)
Upvotes: 1