Advertisement
KevinPerez

Post Request

Jul 6th, 2017
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.84 KB | None | 0 0
  1. @IBAction func loginButtonTouchUpInside(_ sender: UIButton) {
  2.         let username = usernameTextField.text
  3.         let userPassword = passwordTextField.text
  4.         let root = "http://startup-rocket-kperezm.c9users.io/api/v1/"
  5.         let uri = "auth/sign_in"
  6.         let url = "\(root)\(uri)"
  7.        
  8.         if(username!.isEmpty || userPassword!.isEmpty)
  9.         {
  10.             displayAlertMessage(userMessage: "All fields are required")
  11.             return
  12.         }
  13.         let requestParams = ["email": username,
  14.                       "password": userPassword]
  15.        
  16.         Alamofire.request(url, method: .post, parameters: requestParams, encoding: JSONEncoding.default, headers: [:])
  17.             .responseJSON { response in
  18.                 debugPrint(response)
  19.                 self.dismiss(animated: true, completion: nil)
  20.         }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement