Giter Site home page Giter Site logo

Comments (2)

snychka avatar snychka commented on August 23, 2024 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.

RobotCherries avatar RobotCherries commented on August 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.