Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can obtain the error message by providing a second function parameter to the subscribe method. This function is called when an error occurs, and it receives the error object as its parameter. Here is an example:

// assume you have an observable named myObservable

myObservable.subscribe(
  data => console.log(data), // this is the success function
  error => console.log(error) // this is the error function
);

In this example, if an error occurs, the error function will be called and the error message will be logged to the console.