Skip to content

Instantly share code, notes, and snippets.

@dimebt
Created January 28, 2019 15:58
Show Gist options
  • Select an option

  • Save dimebt/02ef68d6c66b13e7935a1a1ca2ed0aea to your computer and use it in GitHub Desktop.

Select an option

Save dimebt/02ef68d6c66b13e7935a1a1ca2ed0aea to your computer and use it in GitHub Desktop.
func promiseFetchJSON() -> Promise<[String: Any]> {
return Promise<[String: Any]> { seal in
fetchJSON(fromURL: "someURL", completion: { (response, results, error) in
switch response {
case .success:
seal.fulfill(results)
case .fail:
seal.reject(error)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment