Hello friends I have the following method that requests the server:
public MetaDataR metodo1(final String m) {
Call<MetaDataR> call2 = new RetrofitConfig().getMetasService().getMetas(m);
call2.enqueue(new Callback<MetaDataR>() {
@Override
public void onResponse(@NonNull Call<MetaDataR> call, @NonNull Response<MetaDataR> response) {
if (response.body() != null) {
MetaDataR iten = response.body(); ////Quero retornar "iten" para o metodo1()
}
}
}
@Override
public void onFailure(@NonNull Call<MetaDataR> call, @NonNull Throwable t) {
// tratar algum erro
Log.e("Erro", "Erro ao buscar:" + t.getMessage());
}
});
return null;
}
This way it returns NULL every time. I need it to return the value that comes from the server, that is, that it waits for the request and returns "iten". Is it possible?