I used Alamofire to make a login page on my app, I managed to log in using the below request
@IBAction func LoginBtn(_ sender: Any) {
struct Login: Encodable {
let email: String
let password: String
}
let login = Login(email: MobileLbl.text!, password: PassLbl.text!)
AF.request("https://site/apis/loginuser.php",
method: .post,
parameters: login,
encoder: JSONParameterEncoder.default).response { response in
debugPrint(response)
}
}
and in the console I got a success login
[Response]:
[Status Code]: 200
[Headers]:
Access-Control-Allow-Origin: *
Content-Length: 23
content-security-policy: upgrade-insecure-requests
Content-Type: text/html; charset=UTF-8
Date: Tue, 12 Jan 2021 14:31:26 GMT
Server: Apache
[Body]:
{"status":"","data":[]}
[Network Duration]: 1.2073789834976196s
[Serialization Duration]: 0.0s
[Result]: success(Optional(23 bytes))
my question is how to navigate to another viewcontoller if success and show error message in failure?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…