所以这困扰了我一阵子。我实际上以为我的代码无法正常工作。我正在使用System.out.println();
测试是否获得了正确的输出,但是控制台一直空白,因此我以为它无法正常工作。
经过进一步调查,它一直在工作,但是一直在打印与控制台相同颜色的文本,使其显示为空白。知道为什么吗?
public APIRequests() {
}
public void UnirestCall(String URL) throws UnirestException {
response = Unirest.get(URL)
.header("x-rapidapi-host", "api-football-v1.p.rapidapi.com")
.header("x-rapidapi-key", APIKEY)
.asJson()
.getBody();
System.out.println("1" + response.toString());
}
public JsonNode countriesRequest() throws UnirestException {
UnirestCall(APIURL.concat("countries/"));
System.out.println("2" + response.toString());
response = getResponse();
return response;
}
public JsonNode getResponse() {
return response;
}
}
主要方法
import apicalls.APIRequests;
public class Main {
public static void main(String[] args) throws UnirestException {
APIRequests request = new APIRequests();
request.countriesRequest();
System.out.println("Test");
System.out.println("3" + request.getResponse().toString());
}
}
当我在控制台中突出显示该行时,将其复制并粘贴到记事本中。
我确定我不能成为第一个遇到此问题的人,我只是找不到答案,所以很抱歉,如果问题已经存在。任何帮助或建议,将不胜感激。