getPost
Fetches a single post by ID from the remote API.
This function makes an HTTP GET request to retrieve a specific post identified by id. The request executes on the IO dispatcher and may throw network-related exceptions.
When to Use
Loading detailed post data
Refreshing a single post
Deep link navigation requiring fresh data
Error Handling
suspend fun fetchPost(id: Int): Result<NetworkPost> = suspendRunCatching {
networkDataSource.getPost(id)
}Content copied to clipboard
Return
A NetworkPost object representing the requested post.
Parameters
id
The unique identifier of the post to retrieve. Must be a positive integer.
Throws
IOException
if network communication fails
HttpException
if the server returns an error response (e.g., 404 if post not found)
SerializationException
if response parsing fails