title: How can I return data in method from Retrofit onResponse?
body: <p>I'm new with retrofit and I want to make my getData method to return a feature object. What is the easiest way to do that?</p>
  
  <p>DataService.java</p>
  
  <pre><code>public class DataService {
  
      private static final String TAG = MainActivity.class.getSimpleName();
      private final ApiClient apiClient;
  
      public DataService() {
          apiClient = new ApiClientFactory().createApiClient();
      }
  
      public List&lt;Feature&gt; getData(){
  
          apiClient.getData().enqueue(new Callback&lt;DataResponse&gt;() {
  
              @Override
              public void onResponse(Call&lt;DataResponse&gt; call, Response&lt;DataResponse&gt; response) {
                  List&lt;Feature&gt; features = response.body().getFeatures();
                  Log.d(TAG, "Data successfully downloaded");
              }
  
              @Override
              public void onFailure(Call&lt;DataResponse&gt; call, Throwable t) {
                  Log.e(TAG, t.toString());
              }
          });
          //I need to return features in getData method
      }
  }
  </code></pre>