Open SEKI-YUTA opened 1 month ago
This issue's work branch is "HealthApp-18". branch name:
HealthApp-18
To checkout this branch, run the following command:
git checkout -b HealthApp-18
このコードで動作確認をした
interface PhotoAPI {
@GET("albums/1/photos")
suspend fun getPhotos(): List<PhotoAPIResponseItem>
companion object {
val BASE_URL = "https://jsonplaceholder.typicode.com/"
suspend fun callPhotosAPI(): List<PhotoAPIResponseItem> {
val client = HttpClient {
install(ContentNegotiation) {
json(Json {
ignoreUnknownKeys = true
isLenient = true
})
}
}
val ktorfit = Ktorfit.Builder()
.httpClient(client)
.baseUrl(BASE_URL)
.build()
return withContext(Dispatchers.IO) {
val photoList = ktorfit.createPhotoAPI().getPhotos()
photoList
}
}
}
}
ktorfit https://foso.github.io/Ktorfit/