D
D
druper2020-06-24 15:51:48
Android
druper, 2020-06-24 15:51:48

What is the correct way to use Retrofit when there are multiple data sources?

For each, I created a separate instance of Retrofit, maybe different headers, interceptors, etc. Now there are a couple more. How to make adding easier? Producing Retrofits is somehow wrong

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2020-06-25
@druper

You need to set up the builder and reuse it, each time creating new retrofit instances for different URLs from one builder.

S
Sergey Vodakov, 2020-06-24
@WaterSmith

Each of your data sources has its own base URL. Each source has its own API. Naturally, you will have to describe the interfaces for each of these APIs and create a separate Retrofit object for each base URL.
There is absolutely nothing wrong here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question