So I am trying to fetch this API response but have not been able to the problem. when I call this below function and debug it at a certain point it fetches the result but as soon as it crosses if block the response disappears. Look at the two images for reference.
Here is the code for that function
public JsonObject getResult() {
System.err.println(" Called getResult: ");
Request request = new Request.Builder()
.url("http://localhost:7005/api/pools")
.build();
try (var response = client.newCall(request).execute()) {
if (!response.isSuccessful()) {
throw new IOException("Unexpected code " + response);
}
ResponseBody responseBody = response.body();
String responseBodyString;
if (responseBody != null) {
responseBodyString = responseBody.string();
} else {
throw new IOException("Response body is null");
}
JsonObject js = gson.fromJson(responseBodyString, JsonObject.class);
return js;
} catch (IOException e) {
System.err.println("[ERROR] " + e.getMessage());
// TODO Try again in x minutes
System.out.print("No Response");
System.err.println("[ERROR] No Response");
return null;
}
}