title: How can I make OkHttp calls synchronous/blocking?
body: <p>OkHttp is usually asynchronous. A regular call looks like this:</p>
  
  <pre><code>client.newCall(request).enqueue(new Callback() {
      @Override
      public void onFailure(Call call, IOException e) {
          e.printStackTrace();
      }
  
      @Override
      public void onResponse(Call call, final Response response) throws IOException {
          if (!response.isSuccessful()) {
              throw new IOException("Unexpected code " + response);
          } else {
              // do something wih the result
          }
      }
  }
  </code></pre>
  
  <p>When the message arrives, just do something with it. But I want to use it as a blocking getter. Something like:</p>
  
  <pre><code>public void exampleMethod() {
     MyDTO myDto = makeOkHttpCall.getData();
     // do something with myDto Entity
  }
  </code></pre>
  
  <p>But all I can find is that I could add code into <code>onResponse()</code>. But that is still asynchronous. Any ideas how to change that?</p>