S
S
SaNsA_St4Rk2021-02-11 16:37:19
Java
SaNsA_St4Rk, 2021-02-11 16:37:19

What is the correct way to send a request to Retrofit2?

I am getting an array after a retrofit FirstArray request, in this array I am getting a list of strings. Each of these rows needs to be sent as a request to another retrofit request, after which I get a SecondArray. How to iterate through the FirstArray array to get the ThirdArray like in the picture? 602532bb2ed32838001555.jpeg
I am getting an array after a retrofit FirstArray request, in this array I am getting a list of strings. Each of these rows needs to be sent as a request to another retrofit request, after which I get a SecondArray. How to iterate through the FirstArray array to get the ThirdArray like in the picture? enter image description here

This is my first experience with Android Studio on java. Please don't throw stones

Call<List<FirstArrResponse>> firstArrResponseCall = ArrClient.getUserService().adDat(firstArrRequest);
        firstArrResponseCall.enqueue(new Callback<List<FirstArrResponse>>() {
            @Override
            public void onResponse(@NotNull Call<List<FirstArrResponse>> call, @NotNull Response<List<FirstArrResponse>> response) {
                if(response.isSuccessful()){
                    List<FirstArrResponse> irstArrResponses = response.body();

                    for (FirstArrResponse firstArrResponse : firstArrResponses){
                       
                        //здесь получаю FirstArray

                        adapterArr.setData(firstArrResponses);
                        list_rv.setAdapter(adapterArr);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-02-11
@zagayevskiy

The easiest way is to use RxJava for this. flatMap.
Or just run N requests with your hands and glue the answers together. There is nothing specific to this task in the retrofit itself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question