tlmarker1968

Untitled

Oct 22nd, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1. The is the function I am using to call the API
  2.  private String getDepartmentName(Integer department) {
  3.         final String[] return_val = new String[1];
  4.         return_val[0] = null;
  5.         managerLauncherApi.getDepartmentName(department, new Callback<List<ObjectDepartment>>() {
  6.             @Override
  7.             public void onResponse(@NonNull Call<List<ObjectDepartment>> call, @NonNull Response<List<ObjectDepartment>> response) {
  8.                 List<ObjectDepartment> JsonList = response.body();
  9.                 for (int i = 0; i < requireNonNull(JsonList).size(); i++) {
  10.                     objectDepartment = new ObjectDepartment(
  11.                             JsonList.get(i).getId(),
  12.                             JsonList.get(i).getDepartment()
  13.                     );
  14.                 }
  15.                 return_val[0] = objectDepartment.getDepartment();
  16.             }
  17.             @Override
  18.             public void onFailure(@NonNull Call<List<ObjectDepartment>> call, @NonNull Throwable t) {
  19.                 return_val[0] = "Department not found";
  20.             }
  21.         });
  22.         return return_val[0];
  23.     }
  24.  
  25. When I debug it, it goes from the managerLAuncherApi line to the return line at the bottom, skipping everything in between.
  26.  
  27. The request I make in Postman: http://phoenixhospman.com/api/launcher/getDepartmentName/5
  28.  
  29. And the result from Postman to the request: [ { "id": 5, "department": "Operations" } ]
Advertisement
Add Comment
Please, Sign In to add comment