Skip to content

Instantly share code, notes, and snippets.

@Danappelxx
Created February 9, 2016 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Danappelxx/8f3409681e20de70c17c to your computer and use it in GitHub Desktop.
Save Danappelxx/8f3409681e20de70c17c to your computer and use it in GitHub Desktop.
//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