Skip to content

Commit

Permalink
Documented FormData support in .send() (#1260)
Browse files Browse the repository at this point in the history
I wanted to use superagent to send an HTML form, because of some `<input type="file">` fields. Browser support section in the master branch's README hints that `FormData` is somehow supported, but I couldn't find any mentions of it in the documentation website. After blindly trying using `.field()` and `.append()`, I found out that it works with `.send()`.
  • Loading branch information
lorenzos authored and kornelski committed Aug 8, 2017
1 parent 9af311f commit 8c95c4f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ SuperAgent formats are extensible, however by default "json" and "form" are supp
.send({ name: 'tj' })
.send({ pet: 'tobi' })
.end(callback)
Sending a [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData) object is also supported. The following example will __POST__ the content of the HTML form identified by id="myForm":

request.post('/user')
.send(new FormData(document.getElementById('myForm')))
.end(callback)

## Setting the `Content-Type`

Expand Down

0 comments on commit 8c95c4f

Please sign in to comment.