Skip to content

Instantly share code, notes, and snippets.

@KrisYu
Created June 26, 2017 23:55
Show Gist options
  • Save KrisYu/1be1400c254d0ccda77f10cd7473503a to your computer and use it in GitHub Desktop.
Save KrisYu/1be1400c254d0ccda77f10cd7473503a to your computer and use it in GitHub Desktop.
import Cocoa
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
if let url = URL(string: "https://api.github.com/users/octocat") {
URLSession.shared.dataTask(with: url){ data, response, error in
if let data = data {
let json = try? JSONSerialization.jsonObject(with: data, options: [])
print(json)
}
}.resume()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment