Created
February 9, 2016 03:04
-
-
Save Danappelxx/8f3409681e20de70c17c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This is the url for my server. | |
let client = Client(base: "www.myblog.com", method: .GET) | |
//This is the api path. | |
let api = client.endpoint("/api/v1", method: .GET) | |
//This endpoint builds off of the api endpoint. | |
let posts = api.endpoint("/posts", method: .GET) | |
//This endpoint takes the response from that endpoint, uses it as a parameter for this endpoint | |
let firstPost = posts.chain { response in | |
// convert response to array somehow | |
let postIDs = parseResponseMagically(response) | |
return posts.endpoint("/" + postIDs[0], method: .GET) | |
} | |
let myFirstPost = firstPost | |
.send(middleware: parseJSON) | |
.serialize { response in | |
return Post(response.content) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment