Я погуглил это дерьмо и не могу найти решение.
Я уже давно использую подобный код. http - это угловой HttpClient.
forgotPassword(email: string): Observable<ApiReturn> {
const url = `${this.apiURL}/ForgotPassword`;
const params = {
email
};
return this.http
.post<ApiReturn>(url, params, this.requestOptions)
.pipe(catchError(e => this.handleError(e)));
}
Я обновился до последней версии Angular 6.x и RxJS 6 (с 5.5). Теперь код жалуется на catchError:
Аргумент типа «OperatorFunction» не может быть назначен параметру типа «OperatorFunction».
Типы параметров «источник» и «источник» несовместимы.
Тип «Наблюдаемый» не может быть назначен типу «Наблюдаемый».
Мой HttpInterceptor также теперь не может скомпилироваться.
import { Injectable } from '@angular/core';
import {
HttpEvent,
HttpInterceptor,
HttpHandler,
HttpRequest,
HttpResponse
} from '@angular/common/http';
import { Log, Level } from 'ng2-logger/client';
import { Observable } from 'rxjs';
import { map, tap } from 'rxjs/operators';
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
constructor() {
}
intercept(
req: HttpRequest<any>,
next: HttpHandler
): Observable<HttpEvent<any>> {
// Get the auth header from the service.
// const authHeader = this.global.authenticationToken;
// Clone the request to add the new header.
const authReq = req.clone({
headers: req.headers
.set('Access-Control-Allow-Origin', window.location.href)
});
// Pass on the cloned request instead of the original request.
return next.handle(authReq);
}
}
Ошибка: [ts] Тип
'Импорта ( "C: / ProjDotNet / collegebowl-сайт / node_modules / @ Угловое / ядро / node_modules / rxjs / внутренний / Наблюдаемый"). Наблюдаемое>'
нельзя назначить типу
'Импорта ( "C: / ProjDotNet / collegebowl-сайт / node_modules / rxjs / внутренний / Наблюдаемый") Заметный>.'.
Типы недвижимости
источник "несовместимы.
В основном та же проблема.
Я понял, что мне не хватает чего-то базового в функции pipe, но я не могу понять это или найти пример, который делает то, что я делаю. Любая помощь будет оценена.