<BlockSwitcher>

<Block name="Async/Await">

```swift
do {
    let result = try await Amplify.DataStore.query(
        Post.self,
        sort: .ascending(Post.keys.rating))
    print("Posts: \(result)")
} catch let error as DataStoreError {
    print("Error listing posts - \(error)")
} catch {
    print("Unexpected error \(error)")
}
```

</Block>

<Block name="Combine">

```swift
let sink = Amplify.Publisher.create {
    try await Amplify.DataStore.query(
        Post.self, 
        sort: .ascending(Post.keys.rating))
}.sink {
    if case let .failure(error) = $0 {
        print("Error listing posts - \(error)")
    }
}
receiveValue: { result in
    print("Posts: \(result)")
}
```

</Block>

</BlockSwitcher>