Skip to content

Instantly share code, notes, and snippets.

@nanoxd
Last active March 30, 2019 21:49
Show Gist options
  • Save nanoxd/505f5adf2736a18e126b6892aea7bd0e to your computer and use it in GitHub Desktop.
Save nanoxd/505f5adf2736a18e126b6892aea7bd0e to your computer and use it in GitHub Desktop.
Request+Result.swift #swift
extension Request where Response: Decodable {
func handle(
response: Result<Data, Error>,
completion: (Result<Response, Error>) -> Void) {
completion(Result {
try JSONDecoder().decode(Response.self, from: response.get())
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment