I am trying to map
from a service call but getting an error.
Looked at subscribe is not defined in angular 2? and it said that in order to subscribe we need to
If your function is expecting to return a boolean, just do this:
import { of, Observable } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
checkLogin(): Observable {
return this.service.getData()
.pipe(
map(response => {
this.data = response;
this.checkservice = true;
return true;
}),
catchError(error => {
this.router.navigate(['newpage']);
console.log(error);
return of(false);
})
)}