Skip to content

Instantly share code, notes, and snippets.

@nicnocquee
Created November 17, 2021 00:03
Show Gist options
  • Save nicnocquee/64be0d558eb20b8517c0f9a8845f1b24 to your computer and use it in GitHub Desktop.
Save nicnocquee/64be0d558eb20b8517c0f9a8845f1b24 to your computer and use it in GitHub Desktop.
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