- перехожу на 6 впервые)
простой сервис с http запросами
import { throwError, Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { CoreConfig } from '../../../core/core.config';
import { catchError } from 'rxjs/operators';
@Injectable()
export class UserService {
constructor(private _http: HttpClient,
private _config: CoreConfig) { }
/***************************************************** GETTERS ****************************************************/
/* Get full users list */
getList() {
let reqURL = this._config.getConfig('prodAppServer') + '/admin/user/list?' +
'token=' + this._userDataService.token;
return this._http.get(reqURL).pipe(
catchError(error => { this._config.handleError(error); })
);
}
}
на выходе имею ошибку
src/app/_shared/service/user/user.service.ts(23,18): error TS2345: Argument of type '(error: any) => void' is not assignable to parameter of type '(err: any, caught: Observable<Object>) => ObservableInput<{}>'.
Type 'void' is not assignable to type 'ObservableInput<{}>'.
что делаю не так?
up попробовал так getUserID() { let reqURL = this._config.getConfig('prodAppServer') + '/user/getid?' + 'token=' + this._userDataService.token; return this._http.get(reqURL).pipe( catchError(val => of(I caught: ${val})) ); } но все равно ошибка Argument of type 'OperatorFunction<Object, string | Object>' is not assignable to parameter of type 'UnaryFunction<Observable<Object>, Observable<string | Object>>'. Types of parameters 'source' and 'source' are incompatible. Type 'Observable<Object>' is not assignable to type 'Observable<Object>'. Two different types with this name exist, but they are unrelated. Property 'source' is protected in type 'Observable<Object>' but public in type 'Observable<Object>'.
Обсуждают сегодня