```swift
func fetchAttributes() async {
do {
let attributes = try await Amplify.Auth.fetchUserAttributes()
print("User attributes - \(attributes)")
} catch let error as AuthError{
print("Fetching user attributes failed with error \(error)")
} catch {
print("Unexpected error: \(error)")
}
}
```
```swift
func fetchAttributes() -> AnyCancellable {
Amplify.Publisher.create {
try await Amplify.Auth.fetchUserAttributes()
}.sink {
if case let .failure(authError) = $0 {
print("Fetch user attributes failed with error \(authError)")
}
}
receiveValue: { attributes in
print("User attributes - \(attributes)")
}
}
```