iOS Swift - Networking
Identify the error in this Swift code for API integration:
let url = URL(string: "https://api.example.com")
let task = URLSession.shared.dataTask(with: url!) { data, response, error in
if error != nil {
print("Failed")
} else {
print("Success")
}
}