How can I solve the problem of returning with an error using capture inside Observable?
I want to execute a function inside catch in order to do some validation before the subscription is done.
Thank you in advance for your great attention.
The error occurs in → .catch ((e) => {console.log (e)})
import { Injectable } from '@angular/core';
import { Headers, Http, ResponseOptions} from '@angular/http';
import { AuthHttp } from 'angular2-jwt';
import { MEAT_API } from '../app.api';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
@Injectable()
export class CompareNfeService {
constructor(private http: AuthHttp) { }
envirArquivos(order): Observable<any> {
const headers = new Headers();
return this.http.post(`${MEAT_API}compare/arquivo`, order,
new ResponseOptions({headers: headers}))
.map(response => response.json())
.catch( (e) => {console.log(e)} );
}
}
Error
ERROR in /XXXXXX/application/src/app/compare/service.ts(28,17): An argument of type '(e: any) => void' is not assigned to type '(err: any, catch: Observable) => ObservableInput <{}> '.
The type 'void' is not assigned to the type 'ObservableInput <{}>'.
source
share