Skip to content

Instantly share code, notes, and snippets.

@quangtqag
Created March 5, 2020 10:06
Show Gist options
  • Save quangtqag/07d439b10c2e25c53b4e1de007e92daf to your computer and use it in GitHub Desktop.
Save quangtqag/07d439b10c2e25c53b4e1de007e92daf to your computer and use it in GitHub Desktop.
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