Last active
December 30, 2017 09:03
-
-
Save frootloops/1250835b3666170a9410b3118d8958a4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func fetchUserId(completion: @escaping (Int?, Error?) -> Void) { | |
let request = URLRequest(url: URL(string: "http://facebook.com/me")) | |
URLSession.shared.dataTask(with: request) { data, response, error in | |
if let data = data { | |
completion(Int(data), nil) | |
} else if error = error { | |
completion(nil, error) | |
} | |
}.resume() | |
} | |
fetchUserId { userId, error in | |
print(userId, error) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment