-
Notifications
You must be signed in to change notification settings - Fork 45
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
How to use this library with Affjax? #51
Comments
After a while, I think I got something. This might not be perfect, as I am quite a noob with purescript, but here it is: transformError (ResponseFormat.ResponseFormatError e _) = cons' e Nil
main = void $ launchAff_ $ do
res <- AX.request (
AX.defaultRequest
{
url = "https://jsonplaceholder.typicode.com/todos/1",
method = Left GET,
responseFormat = ResponseFormat.string
}
)
let body = bimap transfomError identity res.body
case res.body >>= JSON.readJSON of
Right (r :: MyRecordAlias) -> do
log "all good"
Left e -> do
log "all bad"
It was rather easy, perhaps a mention on the docs would be a good idea? |
Yeah, if you'd like you could put that in a new markdown file to go in the docs and PR it |
I'm not so sure about the transform code you have though, doesn't that just end up losing information? Might be better to return a nested either here |
Sure, but...
So if you can suggest improvements it would be great! (I did not know where to fit the |
I know that might not be an issue with the library itself, but as
Affjax
is probably the most famous purescript library for ajax, it would make sense to be able to easily useSimple.JSON
with it.Currently I am getting the following error:
It would be nice to have an easy way to have this transformation.
This is my code:
The text was updated successfully, but these errors were encountered: