Skip to content

Commit

Permalink
Migrate API calls and fixes #36 (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlykotom authored Dec 12, 2024
1 parent 462a303 commit 41a84bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal fun commonCreateApi(): FruittieApi = FruittieNetworkApi(
json(json, contentType = ContentType.Any)
}
},
apiUrl = "https://yenerm.github.io/frutties/",
apiUrl = "https://android.github.io/kotlin-multiplatform-samples/fruitties-api",
)

val json = Json { ignoreUnknownKeys = true }
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import kotlin.coroutines.cancellation.CancellationException
interface FruittieApi {
suspend fun getData(pageNumber: Int = 0): FruittiesResponse
}

class FruittieNetworkApi(private val client: HttpClient, private val apiUrl: String) : FruittieApi {

override suspend fun getData(pageNumber: Int): FruittiesResponse {
val url = apiUrl + "api/$pageNumber"
val url = "$apiUrl/$pageNumber.json"
return try {
client.get(url).body()
} catch (e: Exception) {
Expand Down

0 comments on commit 41a84bf

Please sign in to comment.