Я пытаюсь добавить requesttoption и заголовок, но выдает следующую ошибку
src/app/pages/ldapp/ldapp.service.ts(72,5): error TS2322: Type 'HttpHeaders' is not assignable to type 'Headers'.
Property 'forEach' is missing in type 'HttpHeaders'.
src/app/pages/ldapp/ldapp.service.ts(74,31): error TS2345: Argument of type 'RequestOptions' is not assignable to parameter of type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: Ht...'.
Types of property 'headers' are incompatible.
Type 'Headers' is not assignable to type 'HttpHeaders | { [header: string]: string | string[]; }'.
Type 'Headers' is not assignable to type '{ [header: string]: string | string[]; }'.
Index signature is missing in type 'Headers'
Ниже приведен мой код
import { map } from 'rxjs/operators';
import { HttpClient,HttpHeaders } from '@angular/common/http';
@Injectable()
export class LDappService {
private headers: HttpHeaders;
constructor(){
this.headers = new HttpHeaders();
}
private addAuthorizationHeader = () => {
this.headers.delete('Authorization');
this.headers.append('Authorization', 'Bearer ' + this.appState.get('_a_token'));
}
getladderRequest(gcid, callId, protocol, epoch) {
this.addAuthorizationHeader();
const url = this.baseApiUrl
this.urlParams = new URLSearchParams();
this.urlParams.set('callID', callId);
this.urlParams.set('protocol', 'SIP');
if (gcid != "") {
this.urlParams.set('gcid', gcid);
}
this.urlParams.set('pkey', epoch);
this.requestOptions.search = this.urlParams;
this.requestOptions.headers = this.headers;
return this.http.get(url, this.requestOptions).pipe(map(
res => {
return res;
}));
}
}