getPosts

abstract suspend fun getPosts(): List<NetworkPost>

Fetches all posts from the remote API.

This function makes an HTTP GET request to retrieve a list of posts. The request executes on the IO dispatcher and may throw network-related exceptions.

When to Use

  • Initial data sync

  • Pull-to-refresh operations

  • Periodic background sync

Error Handling

suspend fun fetchPosts(): Result<List<NetworkPost>> = suspendRunCatching {
networkDataSource.getPosts()
}

Return

A List of NetworkPost objects from the remote server.

Throws

IOException

if network communication fails

HttpException

if the server returns an error response

SerializationException

if response parsing fails