我有一个简单的 Json 对象请求类,这是调用整个请求的方法,在 LogCat 中我只得到:
Volley: [2] 2.onErrorResponse: Error:
所以我不知道在哪里寻找修复
private void getBeerDetails() {
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
(Request.Method.GET,
"https://api.punkapi.com/v2/beers/13",
null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
beerName.setText(response.getString("name"));
alc.setText(response.getString("abv"));
ibu.setText(response.getString("ibu"));
firstBrewed.setText(response.getString("first_brewed"));
yeast.setText(response.getString("yeast"));
description.setText(response.getString("description"));
foodPairing.setText(response.getString("food_pairing"));
Picasso.with(getApplicationContext())
.load(response.getString("image_url"))
.into(beerImageView);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("Error:", error.getMessage());
}
});
requestQueue.add(jsonObjectRequest);
}