2

I'm just trying to use the map function but it throws an error.Inside the results.map(results => etc) it says that 'Symbol Map cannot be properly resolved, probably it is located in inaccessible module'

,enter image description here

import { Component, OnInit } from '@angular/core';
import { take, map,filter, tap } from 'rxjs/operators';
etc

@Component({
  selector: 'app-test',
  templateUrl: './test.component.html',
  styleUrls: ['./test.component.css']
})
export class TestComponent implements OnInit {
  public project: IProject;

  constructor(

    private appSer: AppService) { }

  public ngOnInit(): void {

    this.appSer.project$
      .pipe(
        take(1),
        map(results =>
          results.map(result => ({
            ...result,
            square: result.square * 5000

          })))
      )
      .subscribe(
        (result: IProject) => {
          console.log(result);

        },
        (error: any) => {
          console.error(error);
        },

    );
  }
}
2
  • What is the data typeof results? Commented Apr 7, 2020 at 18:17
  • Its a object of IProject Commented Apr 7, 2020 at 18:20

2 Answers 2

4

Since, the type of results is an object remove the extra map operator.

  .pipe(
    map(result => ({
      ...result,
      square: result.square * 5000
    }))
  )

If result was an array then you would need the extra map operator.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, makes sense :D
1

You don't need the second map, just do like so:

      .pipe(
        take(1),
        map(results => ({
            ...result,
            square: result.square * 5000
        }))
      )

(just make sure to match the brackets)

1 Comment

@HJ1990 Added the object braces, try that

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.