Skip to content

Commit

Permalink
Update data/network/src/commonMain/kotlin/social/androiddev/common/ne…
Browse files Browse the repository at this point in the history
…twork/MastodonApiKtor.kt

Co-authored-by: Omid Ghenatnevi <[email protected]>
  • Loading branch information
digitalbuddha and crocsandcoffee committed Dec 21, 2022
1 parent 8744191 commit 5e18ee1
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,11 @@ internal class MastodonApiKtor(
}

override suspend fun getHomeFeed(domain: String, accessToken: String): Result<List<Status>> {
return try {
val url = "https://$domain/api/v1/timelines/home"
val body = httpClient.get(url) {
return runCatchingIgnoreCancelled<<List<Status>> {
httpClient.get("https://$domain/api/v1/timelines/home") {
headers {
append(HttpHeaders.Authorization, "Bearer $accessToken")
}
}.body<List<Status>>()
Result.success(
body
)
} catch (exception: SerializationException) {
Result.failure(exception = exception)
} catch (exception: ResponseException) {
Result.failure(exception = exception)
} }
}.body()
}
}

0 comments on commit 5e18ee1

Please sign in to comment.