Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

solved: Angular Error: Property 'map' does not exist on type 'Observable '.ts(2339)

25.01.2021 (👁1684)

Angular Error: Property 'map' does not exist on type 'Observable<TimeRecord>'.ts(2339)

 

 

Fehlerbeschreibung:

Die Folgefunktion .map kann nicht in angular eingefügt werden. Beispiel .get().map(..)

Property 'map' does not exist on type 'Observable<TimeRecord>'.ts(2339)

 

Lösung:

In neueren Versionen wird map innerhalb von .pipe(map … ) einefügt. In .pipe können mehrere Folge-Bearbeitungen in serie eingefügt werden.

Error in this code

    return this.http

    .get<TimeRecord>(this.URL)

      .map((responseTimeRecord=> {

           return response as TimeRecord;

         }

    )

 

 

 

Richtig

    return this.http

    .get<TimeRecord>(this.URL)

    .pipe(

      map((responseTimeRecord=> {

           return response as TimeRecord;

         }

        )

    )

 

 

Code mit Fehler  component.service.ts

 

Gelöst: Schreibweise in component.service.ts

 

Solved:

 

import { Injectable } from '@angular/core';

import { HttpClient } from "@angular/common/http";

// import {Http, Response} from "@angular/http";

import { BehaviorSubjectObservable } from 'rxjs'

//import  "rxjs/add/operator/map";

import { map } from 'rxjs/operators';

import { TimeRecord } from '../models/time-records.model';

@Injectable({

  providedIn: 'root'

})

export class TimerecordsService {

  private URL : string="https://localhost:44388/api/TimeRecords";

  constructorprivate httpHttpClient  ) { }

  getData():Observable<TimeRecord>{

    

    return this.http

    .get<TimeRecord>(this.URL)

    .pipe(

      map((responseTimeRecord=> {

           return response as TimeRecord;

         }

        )

    )

  }

}



 

 

 

 

Error:

import { Injectable } from '@angular/core';

import { HttpClient } from "@angular/common/http";

// import {Http, Response} from "@angular/http";

import { BehaviorSubjectObservable } from 'rxjs'

//import  "rxjs/add/operator/map";

import { map } from 'rxjs/operators';

import { TimeRecord } from '../models/time-records.model';

@Injectable({

  providedIn: 'root'

})

export class TimerecordsService {

  private URL : string="https://localhost:44388/api/TimeRecords";

  constructorprivate httpHttpClient  ) { }

  getData():Observable<TimeRecord>{

    

    return this.http

    .get<TimeRecord>(this.URL)

      .map((responseTimeRecord=> {

           return response as TimeRecord;

         }

    )

  }

}