question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: this.getField(...).map is not a function

See original GitHub issue

Using angular-tree-component 3.2.3.

In my template:

<tree-root *ngIf="nodes" [nodes]="nodes" class="box left"></tree-root>

In my App Component constructor:

export class AppComponent  { 
    name = 'Angular'; 
    nodes: any;

   public constructor(private service: MyService) {
    this.service.getdata().subscribe(
                    data => this.nodes = data,
                    err => console.error(err),
                    () => console.log('get complete')
                );

As soon as my data callback returns from getting data from my service and tries to add to the nodes property, I get this:

TypeError: this.getField(...).map is not a function
    at TreeNode._initChildren (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:21686:14)
    at new TreeNode (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:21349:18)
    at TreeModel.exports.TreeModel.TreeModel.update (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:21785:28)
    at executeAction (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:670:19)
    at TreeModel.res (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:661:16)
    at TreeModel.exports.TreeModel.TreeModel.setData (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:21776:14)
    at executeAction (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:670:19)
    at TreeModel.res (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:661:16)
    at TreeComponent.exports.TreeComponent.TreeComponent.ngOnChanges (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:22585:24)
    at Wrapper_TreeComponent.ngDoCheck (/TreeModule/TreeComponent/wrapper.ngfactory.js:60:18)
    at View_AppComponent1.detectChangesInternal (/AppModule/AppComponent/component.ngfactory.js:45:27)
    at View_AppComponent1.AppView.detectChanges (http://localhost/node_modules/@angular/core/bundles/core.umd.js:12208:18)
    at View_AppComponent1.DebugAppView.detectChanges (http://localhost/node_modules/@angular/core/bundles/core.umd.js:12355:48)
    at ViewContainer.detectChangesInNestedViews (http://localhost/node_modules/@angular/core/bundles/core.umd.js:12466:41)
    at CompiledTemplate.proxyViewClass.View_AppComponent0.detectChangesInternal (/AppModule/AppComponent/component.ngfactory.js:197:14)

I tried adding “import ‘rxjs/add/operator/map’;” to my service and my component, but that didn’t help.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
bipinmangwani1commented, Oct 25, 2017

Note that root node has to be an array too.

2reactions
indianazhaocommented, Dec 27, 2018

I solved this issue by using toPromise() to return a promise instead of observable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: this.getField(...).map is not a function #226 - GitHub
Using angular-tree-component 3.2.3. In my template: In my App Component constructor: export class AppComponent { name = 'Angular'; ...
Read more >
A simple this.getfield property does not work in the debugger
TypeError : this.getfield is not a function. 1:Console:Exec. undefined. My result is first of all "undefined". When watching a little video ...
Read more >
TypeError: this.getField(...).map is not a function - Bountysource
Using angular-tree-component 3.2.3. In my template: <tree-root *ngIf="nodes" [nodes]="nodes" class="box left"></tree-root>.
Read more >
Angular HTTP GET with TypeScript error http.get(...).map is not ...
When the bundlers tries to eliminate the unused code (a.k.a. tree shaking ), they may decide to keep the code of the map...
Read more >
TypeError: map.get is not a function in JavaScript | bobbyhadz
The "Map.get is not a function" error occurs when we call the `get()` method on a value that is not a `Map` object....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found