0

I'm new to reactive components. I did an api call with webclient and the response was wrapped in a Mono component. Is there a way to check the value assigned to the object class in Mono component received.

The received response is wrapped in Mono<Abc.class>.

class Abc {
  private message;
  private email;
  private status;
}

I want to get the values in message,email,status.

I tried using .block() but received error block()/blockfirst()/blocklast() are blocking, which is not supported in thread reactor-http-nio-4.

Thank you in advance.

Sam
  • 115
  • 2
  • 10

1 Answers1

0

If you want to receive the values inside the Mono/Flux, use flatMap in Mono as below. Let abc be the instance of the Abc class.

Mono.just(abc).flatMap(fields ->{
       String message = fields.getMessage();
       String email = fields.getEmail();
       String status = fields.getStatus();
       //use these values as you want to
       return Mono.just(fields);
    });