<BlockSwitcher>

<Block name="Async/Await">

```swift
func fetchDevices() async {
    do {
        let fetchDeviceResult = try await Amplify.Auth.fetchDevices()
        for device in fetchDeviceResult {
            print(device.id)
        }
    } catch let error as AuthError {
        print("Fetch devices failed with error \(error)")
    } catch {
        print("Unexpected error: \(error)")
    }
}
```

</Block>

<Block name="Combine">

```swift
func fetchDevices() -> AnyCancellable {
    Amplify.Publisher.create {
        try await Amplify.Auth.fetchDevices()
    }.sink {
            if case let .failure(authError) = $0 {
                print("Fetch devices failed with error \(authError)")
            }
        }
        receiveValue: { fetchDeviceResult in
            for device in fetchDeviceResult {
                print(device.id)
            }
        }
}
```

</Block>

</BlockSwitcher>
