Created
November 17, 2021 00:03
-
-
Save nicnocquee/64be0d558eb20b8517c0f9a8845f1b24 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
struct MeResponseData: Decodable { | |
let id: Int | |
let username: String | |
let email: String | |
} | |
func me(authToken: String? = nil) async throws -> MeResponseData { | |
let meData: MeResponseData = try await URLSession.shared.get(pathname: "/users/me", authToken: authToken) | |
return meData | |
} | |
Task { | |
do { | |
// log in first | |
let jwt = try await login(LoginRequestData(identifier: "your email", password: "password here")) | |
let meData = try await me(authToken: jwt) | |
print(meData) | |
} catch { | |
print(error) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment