Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
771 B
2
Indexable
Never
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

let values = ["06786984572365", "06644857247565", "06649998782227"]

request.httpBody = try! JSONSerialization.data(withJSONObject: values)

AF.request(request)                               // Or `Alamofire.request(request)` in prior versions of Alamofire
    .responseJSON { response in
        switch response.result {
        case .failure(let error):
            print(error)
            
            if let data = response.data, let responseString = String(data: data, encoding: .utf8) {
                print(responseString)
            }
        case .success(let responseObject):
            print(responseObject)
        }
}