I recently started learning angular and npm, but encountered an error while trying to replicate some code from a source I found (linked here).
It seems like the error is related to my development environment, but I'm having trouble pinpointing the exact cause.
Below is the snippet of code causing the issue:
return this.http.get('api/cards.json')
.map((response:Response) => <Card[]>response.json().data)
.do(data=>console.log(data))
.catch(this.handleError);
When I look at the .map
function in Visual Studio Code, I receive the following error message:
ts Property 'map' does not exist on type 'Observable'
If I ignore this error and proceed to the browser, I encounter the same message.
This project was generated with angular-cli
, running on Angular version 2.4.4. The server is up and running using the ng serve
command.
I've tried doing some research:
property map does not exist on observable response in angular --> This didn't apply to me as I don't use Visual Studio 2015 and my VS Code is up to date.
Angular 2 2.0.0-rc.1 Property 'map' does not exist on type 'Observable<Response>' --> The solution involving tsc
doesn't work for me even after installing TypeScript globally and restarting VS Code and the server.
Any insights on what might be causing this issue? It appears to be related to something being out of date, but I'm unsure of what needs updating or how to go about it.