-
Notifications
You must be signed in to change notification settings - Fork 30
misleading or missing documentation, must JSON.stringify body #23
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
Comments
@davekaro Well, I think the docs are wrong. I didn't pay attention to this detail when I wrote the docs, will fix them soon as possible. About the idea of request.js doing this, I'm not sure if we should or not do it, but maybe if we detect the content-type is |
Thanks! Yeah I can see if this is a lightweight wrapper for |
As pointed out on #23 fetch requires to stringify the body of the request when the Content-Type is application/json, but actualy we don't do this automaticly and in the docs we were suggesting that we doo which is confusing.
@davekaro I've fixed the docs. I agree with your point but I think that if we can provide the possibility to the user send the body of the request in both ways and document this, it can be be useful. At least I think that it is a bit anoying to need to stringify the body every time I'll do such kind of request. I'll close the issue, since the docs match the behavior but I will work on supporting this functionality and then we can see what the other folks think about |
References #23 This allows us the make the request sending a javascript object and then RequestJS does the job of stringify the body.
I tried to follow the doc example to
patch
to my rails server:but noticed that
[object Object]
was being sent as the body. Looking at samples on https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch, I updated my code to stringify the JSON payload first.Is this expected or did I miss something? Should the library do this for us? Maybe when the detected content type is
application/json
(request.js/src/fetch_request.js
Line 73 in 0eda429
body
?The text was updated successfully, but these errors were encountered: