Skip to content

Instantly share code, notes, and snippets.

@minhwang
Last active November 8, 2016 10:18
Show Gist options
  • Save minhwang/ac46f3056bd14705df5ff3a1641a9351 to your computer and use it in GitHub Desktop.
Save minhwang/ac46f3056bd14705df5ff3a1641a9351 to your computer and use it in GitHub Desktop.
How to write code to request GET data using String object.
func requestGETUsingString(stringURL url:String) {
guard let url: URL = URL(string: url) else {
print("URL is invalid..!!")
return
}
guard let result = try? String(contentsOf: url) else {
print("Error occurred while getting data..!!")
return
}
print(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment