How to throw an observable error manually?

后端 未结 8 1474
慢半拍i
慢半拍i 2020-12-02 16:35

I am working on an Angular app in which I am making a rest call through HTTP as below:

login(email, password) {
    let headers = new Headers();
    headers.a         


        
8条回答
  •  無奈伤痛
    2020-12-02 17:01

    rxjs 6

    import { throwError } from 'rxjs';
    
    if (response.success == 0) {
      return throwError(response);  
    }
    

    rxjs 5

    import { ErrorObservable } from 'rxjs/observable/ErrorObservable';
    
    if (response.success == 0) {
      return new ErrorObservable(response);  
    }
    

    What you return with ErrorObservable is up to you

提交回复
热议问题