<BlockSwitcher>

<Block name="Async/Await">

```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)")
    }
}
```

</Block>

<Block name="Combine">

```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)")
        }
}
```

</Block>

</BlockSwitcher>
