Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The is the function I am using to call the API
- private String getDepartmentName(Integer department) {
- final String[] return_val = new String[1];
- return_val[0] = null;
- managerLauncherApi.getDepartmentName(department, new Callback<List<ObjectDepartment>>() {
- @Override
- public void onResponse(@NonNull Call<List<ObjectDepartment>> call, @NonNull Response<List<ObjectDepartment>> response) {
- List<ObjectDepartment> JsonList = response.body();
- for (int i = 0; i < requireNonNull(JsonList).size(); i++) {
- objectDepartment = new ObjectDepartment(
- JsonList.get(i).getId(),
- JsonList.get(i).getDepartment()
- );
- }
- return_val[0] = objectDepartment.getDepartment();
- }
- @Override
- public void onFailure(@NonNull Call<List<ObjectDepartment>> call, @NonNull Throwable t) {
- return_val[0] = "Department not found";
- }
- });
- return return_val[0];
- }
- When I debug it, it goes from the managerLAuncherApi line to the return line at the bottom, skipping everything in between.
- The request I make in Postman: http://phoenixhospman.com/api/launcher/getDepartmentName/5
- And the result from Postman to the request: [ { "id": 5, "department": "Operations" } ]
Advertisement
Add Comment
Please, Sign In to add comment