Hey I am working in ktor. I am following this answer. I want to use responsePipeline on my androidMain. But I am getting error Unresolved reference: responsePipeline
. Actually I created my HttpClient with OkHttp in my androidMain. I don't know why I cannot use in my file. Can someone please guide me.
androidMain
actual fun httpClient(config: HttpClientConfig<*>.() -> Unit) = HttpClient(OkHttp) {
responsePipeline.intercept(HttpResponsePipeline.Transform) {
}
config(this)
install(Logging) {
logger = Logger.SIMPLE
level = LogLevel.BODY
}
}
commonMain
expect fun httpClient(config: HttpClientConfig<*>.() -> Unit = {}): HttpClient
Error
responsePipeline
is a property ofHttpClient
class, and you are trying to access it on an instance ofHttpClientConfig
.Lamda of
HttpClient(OkHttp)
returns an object of typeHttpClientConfig
which doesn't have a property namedreponsePipeline
.To use
responsePipeline
you have to create an instance ofHttpClient
, and after that you can use it.You can create a method which returns your configured
httpClient
Assign this to the actual definition.