Could not advance using next()

I have a list of objects which I would like to return in Spring rest API and then read it as an array of objects in Angular:

public Stream<PaymentTransactions> findListByReference_transaction_id(Integer id);

I tried this:

@GetMapping("/reference_transaction_id/{id}")
public List<ResponseEntity<PaymentTransactionsDTO>> getByListReference_transaction_id(@PathVariable String id) {
    return transactionService
            .findListByReference_transaction_id(Integer.parseInt(id))
            .map(mapper::toDTO)
            .map(ResponseEntity::ok).collect(Collectors.toList());
}

But when I try to read it as an Angular Array I get could not advance using next() What is the proper way to return a List from the rest endpoint?

Edit:

@GetMapping("{id}")
    public ResponseEntity<List<ResponseEntity<PaymentTransactionsDTO>>> get(@PathVariable String id) {
        return ResponseEntity.ok(transactionService
                .findListById(Integer.parseInt(id)).stream()
                .map(mapper::toDTO)
                .map(ResponseEntity::ok).collect(Collectors.toList()));


#java #angular #typescript #spring

7 Likes18.10 GEEK