Chapter 23: OkHttpClient and Retrofit

Hi there, in the snippet below, we’re creating a “special” okHttpClient instance but never using it after we call the client.build method.

Aren’t we supposed to inject it to the Retrofit instance so it actually uses the okHttp interceptors we intended to use?

CleanShot 2021-07-23 at 17.54.51@2x

Since not having those interceptors won’t break the code (if we get the reply in <30 secs and don’t care about the logs), it’s hard to notice the problem.

I hope it makes sense.
Thanks!

You are correct. #1 needs to be added after Retrofit.Builder():

.client(client.build())

We will add an issue to github

1 Like

perfect! I tried to do it by myself but had some dependency problems. ended up not using the client since both iTunes API and my network are pretty stable at the time being. (#wfh xD)

I think it would be helpful if you could mention why we are doing what we are doing at that step. at first it feels like we did it for the logging, but we also add a println, which leads to some sort of a false-positive.

This code is not working

Can you give more details?