'Access value in Subscribe's completed

I am subscribing an Observable as follows:

    this.service.post(request).subscribe(
        
        (value: Response> => { 

          // Do something with value

        },

        (error) => {
          this.state = State.Invalid;
          // Show errors on page
        },

        () => { 
          this.state = State.Completed;

          // Redirect to new page:
          this.router.navigate(['done'], { state: { v: value } });
        }

      );

Basically I am posting a request to an API and then I need to:

  1. Do something with the returned value;
  2. Show errors when an error exist
  3. Redirect to new page when returned value is processed.

How to access value in completed? This is why I need to access it:

      this.router.navigate(['done'], { state: { v: value } });

Should I move this line to the next function?

   (value: Response> => { 

     // Do something with value
     // Redirect here

   }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source