Created
August 18, 2020 04:29
-
-
Save simrandotdev/de404ce7e43a038930f0518079080a9d to your computer and use it in GitHub Desktop.
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
import UIKit | |
import Foundation | |
func loadData() { | |
do { | |
guard let url = URL(string: "https://reqres.in/api/users/1") else { return } | |
var request = URLRequest(url: url) | |
request.httpMethod = "DELETE" | |
URLSession.shared.dataTask(with: request) { (data, response, error) in | |
if let error = error { | |
print("Something went wrong with the request: \(error.localizedDescription)") | |
return | |
} | |
guard let _ = data else { | |
print("No data found.") | |
return | |
} | |
guard let httpResponse = response as? HTTPURLResponse else { | |
return | |
} | |
print("\(httpResponse.statusCode)") | |
}.resume() | |
} catch let error { | |
print(error.localizedDescription) | |
} | |
} | |
loadData() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment