-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass details from request in on-success
and on-error
#7
Comments
Indeed that would be needed !
|
I'm having this issue currently. Some of the data I need is in response headers. The third option to provide :xhr as a map of the content :status, :headers, :response-raw. would solve all of my problems. |
+1 on this, need details inside the http request |
Any updates on this? |
Please see the "Tip" at the bottom of the README |
This should unify the shape of the map passed to both on-success and on-failure handlers for all types of situations. Headers are now also provided. As it is a breaking change it is introduced as a new fx handler. Fixes day8#7
Turns out there are at least four different types of situations in which one may receive a value in an event handler:
Up to now the behavior has been:
To fix this properly to return a uniform value a breaking change is needed. The value will always be a map of the shape: {:uri ""
:last-method ""
:headers {:location ""}
:status 201
:status-text ""
:response {:answer 42}}
Other new fx handlers |
This should unify the shape of the map passed to both on-success and on-failure handlers for all types of situations. Headers are now also provided. As it is a breaking change it is introduced as a new fx handler. Fixes day8#7
0.2.0 and 0.2.1 seem to be released, but somewhat confusingly the 0.2.0 goal is still open, so this one hasn't made it to release either. |
@hoxu Thanks for pointing out the inaccuracy with milestones vs actual releases. I have fixed that. Initial intent was to release this and some other changes as 0.2.0 but we ended up doing a lot of work on experimental alternatives None of those are canonical re-frame replacements for this project yet.
Lastly, we're not working on this project here at the moment, but I will look at and might accept pull requests that don't break backwards compatibility. |
Ther is a way to pass through the repsonse headers. For that you'll need to write a custom
You can look at If the call succeeds you should get a map corresponding to what returned the fn you declared in I know this is not the easiest implementation ever but it does the trick. I also used it to set custom request parameters like
For more info, read https://github.com/JulianBirch/cljs-ajax/blob/master/docs/formats.md I hope this can help. |
FYI, some relevant discussion on Clojurian's Slack. The conclusion was that one should probably opt for re-frame-fetch-fx over re-frame-http-fx these days. |
It's often useful to have things like status codes, headers, e.t.c. even in successful responses, e.g. when getting a 201 with a
Location
header. Currently we only return the body of the response. There's a few things to think about here::response
and:xhr
, or extract the useful keys from the Xhr and put them in the map?The text was updated successfully, but these errors were encountered: