Created
March 5, 2020 10:06
-
-
Save quangtqag/07d439b10c2e25c53b4e1de007e92daf 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
static func deleteUser(id: Double, comletionHandler: @escaping (_ error: Error?) -> Void) { | |
let endpointUrl = URL(string: String(format: host + deleteUserPath, id))! | |
var urlRequest = URLRequest(url: endpointUrl) | |
urlRequest.httpMethod = "DELETE" | |
let task = URLSession.shared.dataTask(with: urlRequest) { (data, response, error) in | |
guard error == nil else { | |
print("error calling DELETE on \(deleteUserPath): \(error!)") | |
DispatchQueue.main.async { | |
comletionHandler(error) | |
} | |
return | |
} | |
DispatchQueue.main.async { | |
comletionHandler(nil) | |
} | |
} | |
task.resume() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment