Skip to content

Instantly share code, notes, and snippets.

@catalinaturlea
Created September 25, 2019 19:04
Show Gist options
  • Save catalinaturlea/500ed98658b263dcc77ec4666b786be6 to your computer and use it in GitHub Desktop.
Save catalinaturlea/500ed98658b263dcc77ec4666b786be6 to your computer and use it in GitHub Desktop.
UserService-version1
class UserService {
static var loginURL = "https://my.app.com/login"
static var shared = UserService()
func login(email: String, password: String, completion: (Bool, Error?)) {
let params = ["email": email, "password": password]
Alamofire.shared.request(loginURL, method: .POST, parameters: params, encoding: .URLEncoding).responseJSON { (response) in
switch respose.status {
case .succeeded:
completion(true, nil)
case .error(let error):
completion(false, error)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment