Skip to content

Instantly share code, notes, and snippets.

@dimebt
Created January 28, 2019 15:58
Show Gist options
  • Save dimebt/cb98125327d7b6892b500a8bc7d6e463 to your computer and use it in GitHub Desktop.
Save dimebt/cb98125327d7b6892b500a8bc7d6e463 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