I am making a POST
call with Swift using the Alamofire library. The service call works, but I need to verify the email and the password typed by the user.
How do I pass variables email
and senha
into parameters
of JSON?
Thank you very much in advance. Here's the part of my code that I'm in need of help with:
let URL = NSURL(string: "http://jsonplaceholder.typicode.com/posts")!
let mutableURLRequest = NSMutableURLRequest(URL: URL)
mutableURLRequest.HTTPMethod = "POST"
let parameters = ["title": "Frist Psot", "body": "I iz fisrt", "userId": 1]
do {
mutableURLRequest.HTTPBody = try NSJSONSerialization.dataWithJSONObject(parameters, options: NSJSONWritingOptions())
} catch{
}
mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
Alamofire.request(mutableURLRequest)
.responseJSON { response in
print(response.response) // URL response
print(response.result)
if let JSON = response.result.value {
print("JSON: \(JSON)")
let usuario = JSON.objectForKey("data");
print(usuario)
//String nome = JSON.objectForKey("nome") == nil ? "" :JSON.objectForKey("nome") as! String;
}
}