I got a response from my Alamofire post request. I want to get the Status code from the response. Here in the code:
case .success(let upload, _, _):
upload.responseJSON { response in
print(response.result.value!)
}
Here is the response looks like:
The value
property of the response's result is a dictionary. You can extract status like this:
let json = response.result.value as? [String: Any]
if let status = json?["status"] as? Int {
print(status)
}
struct ProfileModel: Codable {
let status: Int
let type: String
let data: ProfileDataModel
}
struct ProfileDataModel: Codable {
let ImagePath: String
let ThumbImagePath: String
}
struct ProfileModel: Codable { let status: Int let type: String let data: ProfileDataModel } struct ProfileDataModel: Codable { let ImagePath: String let ThumbImagePath: String }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.