From the answer documentation :
@Nullable
public T body()
From a deserialized response body to a successful response.
This means that it response.body()can return null, and as a result, the call response.body().getItems()can call NullPointerException. To avoid a warning, be sure response.body() != nullto call the methods on it before.
Edit
, , . :
mAdapter.addItems(response.body().getItems());
:
if (response.body() != null) {
mAdapter.addItems(response.body().getItems());
}
(, ) , response.body() , . , :
MyClass body = response.body();
if (body != null) {
mAdapter.addItems(body.getItems());
}