Skip to content
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

Suggestion: Allow json objects as payload #113

Closed
n321203 opened this issue Jan 5, 2016 · 2 comments
Closed

Suggestion: Allow json objects as payload #113

n321203 opened this issue Jan 5, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@n321203
Copy link

@n321203 n321203 commented Jan 5, 2016

Wreck supports strings, buffers and streams as payload when doing a post/put/patch. I would suggest adding support for JSON objects, just because it would be beautiful to be able to write

Wreck.post("/endpoint", {payload: {"some":"data"}}, callback)

Maybe implemented by calling JSON.stringify() on the payload if typeof payload == "object" (which would include arrays as well) and set the application/json header.

Just an idea.

@hueniverse

This comment has been minimized.

Copy link
Member

@hueniverse hueniverse commented Jan 6, 2016

wreck was designed to be small and simple. At some point you end up with request.

@hueniverse hueniverse added the request label Jan 6, 2016
@geek

This comment has been minimized.

Copy link
Member

@geek geek commented Jan 6, 2016

@n321203 this is a common use case and I like the idea. I am happy to accept a PR for this with stringify. I just hope we don't end up with bugs from throws when people try to stringify objects with circular references, then we will end up needing something like safe stringify. We will want to make it clear in the documentation that we aren't doing anything to prevent the throw... and I would prefer to avoid adding another dependency.

@geek geek added feature and removed request labels Aug 3, 2016
@geek geek self-assigned this Aug 3, 2016
@geek geek added this to the 9.0.0 milestone Aug 3, 2016
@geek geek closed this in #143 Aug 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.