Hi guys, I’m struggling with a piece of code while...
# spring
c
Hi guys, I’m struggling with a piece of code while trying to use coroutines. I’m calling Spring’s
reactive.function.client
method
awaitBody()
from a Generic class and am running into error:
Copy code
Kotlin: Cannot use 'Response' as reified type parameter. Use a class instead.
---
Copy code
class ReactiveWebClient<Request: Any, Response: Any> {

    suspend fun post(uri: URI, request: Request, headers: (HttpHeaders) -> Unit): Response {
        return <http://webClient.post|webClient.post>()
            .uri(uri)
            .body(BodyInserters.fromValue(request))
            .headers(headers)
            .retrieve()
            .awaitBody()  // error on this line
    }
}
Signature of `awaitBody`:
Copy code
public suspend inline fun <reified T : kotlin.Any> org.springframework.web.reactive.function.client.WebClient.ResponseSpec.awaitBody(): T { /* compiled code */ }
Can someone please help? I’m not so well versed with Kotlin’s type parameters. Slack Conversation