In my Angular-12 application, I have this code in the service:
constructor(private http: HttpClient, private router: Router) {
var currentUser = JSON.parse(localStorage.getItem('user')|| '{}');
this.token = currentUser && currentUser.token;
}
public getAllCountries(): Observable<any> {
const httpOptions = {
headers: new HttpHeaders({
"Content-Type": 'application/json',
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Origin, Authorization, Content-Type, Accept",
"Authorization" : "Bearer " + this.token
})
};
return this.http.get(this.apiUrl + '/fetchCountries', httpOptions )
.pipe(
map((response: Response) => {
return response;
})
);
}
This line is highlighted:
map((response: Response) => {
return response;
Then I got this error:
Argument of type 'OperatorFunction<Response, Response>' is not assignable to parameter of type 'OperatorFunction<Object, Response>'.
The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
Type 'Object' is missing the following properties from type 'Response': headers, ok, redirected, status, and 12 more.ts(2345)
How do I get it resolved?
Thanks