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.

Fixed: The required column was not present in the results of a 'FromSql' operation in asp.net core EF core

Severity Code Description Project File Line Suppression State Error Unable to resolve dependencies. 'Xamarin.Android.Support.Design 24.2.1' is not compatible with 'Xamarin.Forms 2.3.3.180 constraint: Xamarin.Android.Support.Design (= 23.3.0)'. 0