I have error when sending GET request using Okhttp?

Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
I have the following code
OkHttpClient client; Request request = new Request.Builder() .url("http://private-anon-2e719df222-newsapitest.apiary-proxy.com/api/news/football") .build(); Response response = client.newCall(request).execute();

But when you send the request client.newCall(request).execute() with the error:
Attempt to invoke virtual method 'okhttp3.Call okhttp3.OkHttpClient.newCall(okhttp3.Request)' on a null object reference
I understand that for some reason the request is not formed, but can't figure out what that is. Please tell me what could be the reason?
by | 12 views

1 Answer

0 like 0 dislike
Because client is not initialized. The error says exactly that, for the above code it shows.
I think the link to the documentation will be more complete advice on how to initialize.

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked May 22, 2019 by jwwwe
110,608 questions
257,186 answers
35,405 users