0
I’m consuming data of a certain API for login, she returns the Token
of correct access, and otherwise returns the ERROR, but I cannot move to another screen if the fields are filled correctly, follow the API code below:
let postString = "usuario=" + user + "&senha=" + _psw
request.httpBody = postString.data(using: .utf8)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data, error == nil else {
print("error=\(String(describing: error))")
self.alert(title: "Ops!", msg: "Login inválido.")
return
}
// let httpStatus = response as? HTTPURLResponse
if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 {
print("statusCode should be 200, but is \(httpStatus.statusCode)")
}
let responseString = String(data: data, encoding: .utf8)
print("responseString = \(String(describing: responseString))")
}
task.resume()
}
Junior, I don’t understand what you mean by "I can’t move to another screen...". At what point would you like to make this transition?
– Andreza Cristina da Silva