在Android客户端上我正在使用HTTP请求的改造,我遇到了GET方法的问题;我如何获取用户的特定字段,例如,我想将用户名存储到变量name = response.getUserName();
中。界面因某种原因始终返回null
//This the API GET
@GET("api/user")
Call<List<Users>> listUsers();
//This is the restClient
/**
* Getting all the users from the
* REST API and mongoDB
* @return
*/
public List<Users> getUsers(){
Call<List<Users>> userList = service.listUsers();
userList.enqueue(new Callback<List<Users>>() {
@Override
public void onResponse(Call<List<Users>> call, Response<List<Users>> response) {
/**
* The is isSuccessful method find out
* if the status code is in the range 200-300,
* indicating success.
*/
if(response.isSuccessful()){
users = response.body();
callback.resultReady(users);
}
}
//Here is the callbackInterface
public interface ResulReadyCallBack {
public void resultReady(List<Users> users);
}