I am making a request with Okhttp and in the onResponse() method I am storing in variable myResponse the result of that request, my question is, how can I make the method peticion() return the value of the Variable myResponse , I would appreciate example of code since I am still not very good programming, thanks in advance
public String peticion(){
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
String myResponse = response.body().string();
}
}
});
return
}