Created
December 8, 2018 17:21
-
-
Save timle8n1/09c7cf4cb9d2c6b3fb45ed904a2493ce to your computer and use it in GitHub Desktop.
Making a JSON Request on Mac OS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let urlSession = URLSession(configuration: .default) | |
guard let url = URL(string: "https://reqres.in/api/user") else { return } | |
let task = urlSession.dataTask(with: url) { data, response, error in | |
guard let content = data, | |
let json = try? JSONSerialization.jsonObject(with: content) else { return } | |
print(json) | |
} | |
task.resume() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment