Observable is not accepting Catch

0

Please see the figure below;

Why is Observable not accepting catch ?

    
asked by anonymous 29.06.2018 / 19:40

2 answers

1

To use the 'Catch' operator, you need to import it from the rxjs library in this way:

import 'rxjs/add/operator/catch';

So you'll be able to use it.

    
04.07.2018 / 01:35
0

As the Observable is asynchronous, try / catch does not work. You should set an error callback as the example below angular documentation :

myObservable.subscribe({
  next(num) { console.log('Next num: ' + num)},
  error(err) { console.log('Received an errror: ' + err)}
});
    
29.06.2018 / 19:57