SpringBoot | Getting null after success response body when request with token

278 Views Asked by At

Returning a response in SpringBoot project like this:

@GetMapping("/users")
public ResponseEntity<List<UserDto>> getUsers() {
    return ResponseEntity.ok(adminService.getUsers());
}

AdminService method:

@Override
public List<UserDto> getUsers() {
    return userRepo.findAll()
            .stream()
            .map(this::convertEntityToDto)
            .collect(Collectors.toList());
}

I'm getting users but with null after the success body like this:

[
{
    "id": 7,
    "title": "title",
    "description": "describtion",
    "email": "[email protected]",
    "creationDate": "2022-04-21T12:17:40.000+00:00",
    "plannedFinishDate": "2022-04-21T12:17:40.000+00:00"
},
{
    "id": 8,
    "title": "title2",
    "description": "describtion2",
    "email": "[email protected]",
    "creationDate": "2022-04-21T12:17:40.000+00:00",
    "plannedFinishDate": "2022-04-21T12:17:40.000+00:00"
}
]null

I tried this without postman (in iOS project with alamofire) but still null is here.

0

There are 0 best solutions below