Property 'map' does not exist on type 'Observable' while upgrade to Angular 6/7/8/9 from Angular 5/4/2

Error - Property 'map' does not exist on type 'Observable<Response>'

Root Cause - When you upgrade your application from Angular 2/4/5 to Angular 6/7/8/9 then there are some functions that can not support in major versions. 

Solution - To get rid of this error change your import statements as below.

import { Observable } from 'rxjs';
import { catchError, map } from 'rxjs/operators';

And change your implementation for map function as below using 'Pipe' function.

delete(url: string, options?: any): Observable<any> {
        return this._http.delete(`${this._baseUrl}${url}`, options)
            .pipe(
                map(result => {
                    return result;
                }),
                catchError((e: any) => Observable.throw(this.errorHandler(e)))
            );
    }

Thanks!!!

Comments

Popular posts from this blog

Swagger for Azure functions: Undocumented TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body. Fixed.

System.Net.Http.HttpClient' does not contain a definition for 'PostAsJsonAsync

A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance