I'm trying to learn rxjs observables for an ionic project. I've made some headway, but am stuck on a syntax error that I have no idea what it means. The message appeared after I added the pipe to the http.get.
Any ideas of what is wrong and how to fix it would be very welcome:
TS2740: Type '{ (): Observable ; (op1: OperatorFunction ): Observable; (op1: OperatorFunction , op2: OperatorFunction...>): Observable...>; (op1: OperatorFunction...>, op2: OperatorFunction...>, op3: OperatorFunction...>): Observable...>; (op1: OperatorFunction......' is missing the following properties from type 'Observable ': _isScalar, source, operator, lift, and 6 more.
My code is:
// Ionic Modules
import { catchError, map } from 'rxjs/operators';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs-compat/Observable';
import { pipe, throwError } from 'rxjs';
// Models
import { Game } from '../models/game';
import { GamesList } from '../models/games-list';
// Other Modules
import { environment } from '../environments/environment';
@Injectable({
providedIn: 'root'
})
export class GamesProvider {
constructor(
private http: HttpClient
){}
/**
* @summary Retrieve the full games list
* @returns The returned games list data
*/
public getGamesAll(): Observable<GamesList> {
console.log('GamesProvider, in getGamesAll');
return this.http.get(environment.API_URL, {responseType: 'json'}).pipe{
map(data => {
return new GamesList(data);
}),
catchError(err => {
console.error(err);
return throwError('Something went wrong ;)');
});
}
}
}