Created
February 8, 2018 13:55
-
-
Save PauloLeon/24a31c29987afde69203844581ec6893 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static func signin(_ data: URLRequestParams, success: @escaping (User) -> Void, failure: @escaping (ApiError) -> Void ){ | |
var data = URLRequestParams() | |
data["usuario"] = "nayanne.moritsuka+tcr6@terras.agr.br" | |
data["senha"] = "1234" | |
// da um break na linha abaixo, e ve se a variavel data ta populada | |
Alamofire.request(Router.login(data: data)) | |
.validate() | |
.responseJSON { response in | |
switch response.result { | |
case .success: | |
let json = try! JSON(data: response.data!) | |
// da outro break aqui e ve o json como está, se vem os dados certos. | |
success(User(fromJSON: json)) | |
//dentro da tua classe User, também da break no init, para ver se está populando certo. | |
case .failure(_): | |
let apiError = ApiError(response: response) | |
failure(apiError) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment