✅ SOLVED
It prints the response, but the scope is not getting finished (or the program doesn’t exit after the response).. What am i missing here? 🧵
theapache64
03/04/2022, 10:26 AM
Full code :
Copy code
@JsonClass(generateAdapter = true)
data class MockResponse(
@Json(name = "description")
val description: String, // Internal Server Error
@Json(name = "statusCode")
val statusCode: Int // 500
)
interface Api {
@GET("200")
suspend fun get200(): Response<MockResponse>
}
fun main() = runBlocking {
val retrofit = Retrofit.Builder()
.baseUrl("<https://mock.codes/>")
.addConverterFactory(MoshiConverterFactory.create())
.build()
val api = retrofit.create(Api::class.java)
println(api.get200().body())
}