Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Clarify behavior of options.data #41

Merged
merged 1 commit into from

2 participants

@iamnoah

I got bit by this. I assumed a data object would be encoded as JSON and couldn't figure out why the server was giving me a 415.

@ayoung ayoung merged commit 98bf226 into danwrong:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 30, 2011
  1. @iamnoah
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 README.md
View
4 README.md
@@ -68,7 +68,9 @@ All of these attempt to turn the response into a JavaScript object. In order to
* _method_ Request method, can be get, post, put, del
* _query_ Query string variables as a javascript object, will override the querystring in the URL
-* _data_ The data to be added to the body of the request. Can be a string or any object
+* _data_ The data to be added to the body of the request. Can be a string or any object.
+Note that if you want your request body to be JSON with the Content-Type `application/json`, you need to
+JSON.stringify your object first. Otherwise, it will be sent as `application/x-www-form-urlencoded` and encoded accordingly.
* _parser_ A function that will be called on the returned data. try parsers.auto, parsers.json etc
* _encoding_ The encoding of the request body. defaults to utf8
* _headers_ a hash of HTTP headers to be sent
Something went wrong with that request. Please try again.