Created
January 16, 2023 19:08
-
-
Save dinotrnka/69b9c44592bbfac2945da90f9bb3ba37 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
import Foundation | |
class LoginViewModel: ObservableObject { | |
@Published var username: String = "" | |
@Published var password: String = "" | |
@Published var error: APIError? // Added this | |
func login() { | |
LoginAction( | |
parameters: LoginRequest( | |
username: username, | |
password: password | |
) | |
).call { response in | |
self.error = nil // Added this | |
Auth.shared.setCredentials( | |
accessToken: response.data.accessToken, | |
refreshToken: response.data.refreshToken | |
) | |
} failure: { error in | |
self.error = error // Added this | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment