mirror of https://github.com/vapor/docs.git
Merge pull request #109 from vapor/Casperhr-form-data-ex
Updated with a form-data example
This commit is contained in:
commit
2417d36d87
|
|
@ -30,11 +30,21 @@ try drop.client.get("https://api.spotify.com/v1/search", query: ["type": "artist
|
|||
|
||||
In addition to `GET` requests, Vapor's client provides support for most common HTTP functions. `GET`, `POST`, `PUT`, `PATCH`, `DELETE`
|
||||
|
||||
### POST as json
|
||||
```swift
|
||||
let bytes = myJSON.makeBytes()
|
||||
try drop.client.post("http://some-endpoint/json", headers: ["Auth": "Token my-auth-token"], body: .data(jsonBytes))
|
||||
```
|
||||
|
||||
### POST as x-www-form-urlencoded
|
||||
```swift
|
||||
try drop.client.post("http://some-endpoint", headers: [
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
], body: Body.data( Node([
|
||||
"email": "mymail@vapor.codes"
|
||||
]).formURLEncoded()))
|
||||
```
|
||||
|
||||
### Full Request
|
||||
|
||||
To access additional functionality or custom methods, use the underlying `request` function directly.
|
||||
|
|
|
|||
Loading…
Reference in New Issue