Comments (2)
Hello @khashashin ! This I believe is the proper way when using the newer rxjs and likely HttpClient.
Given the set up though, this won't work, as the map function here is part of the observable and not a function on its own you can pass into the pipe argument. Not only do the tests error out, but the site doesn't function. (You get, when you run the given Project set up a "map is undefined" error.)
Instead, you want to just use map
as follows, as a method on the returned Observable:
return this._http.get(this._albumUrl).map(response => <Album>response.json());
If you have any issues in Projects, please post in the Discussion tab for help (feel free to post here as well, but it's not monitored as frequently).
Happy coding!
from angular-albumstoreproductpage.
The above is true for the currently part 3 task 11
@ep-adam-hinder's solution worked:
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { map } from 'rxjs/operators';
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs/Observable';
import { Album } from './album';
Also Important: you will have to declare your own Album interface as it is not to be found anywhere in the project.
getAlbum(id: number): Observable<Album> {
return this._http.get(this._albumUrl)
.pipe(map(response => <Album>response.json()));
.map(response => <Album>response.json());
}
Please update the project's code, especially for beginners it is very bad to learn angular by using deprecated code.
from angular-albumstoreproductpage.
Related Issues (20)
- Deprecated packages
- Project not building HOT 5
- NPM install not working HOT 3
- I found the solution for windows:
- #deprecated packages
- NPM packages not working HOT 1
- No projects support the 'serve' target. HOT 1
- The project is too old
- 10 major versions behind
- Cannot generate node_modules file HOT 1
- Part 3, a lack of an img end tag causes a failure
- Part 6, fails on space before `response.json()` in getProducts HOT 5
- Review Carolina's update
- Project will not build or run HOT 1
- Please rework this tutorial multiple npm package issues
- Can't Check Work
- Users cannot pass module 6 task 1 HOT 1
- Import checks are very restrictive
- Module 6 task 17 test fails on Module 7 or complete tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-albumstoreproductpage.