Lazy loading - adding a 'type' field for hierarchy

I have another question - I am trying to load dynamically for Webix tree-

This is the code I currently have:

//For ROOT

  1. url:‘api/fulltree/getChildrenOfNode?nodeType=root’,
    // For [sub] directories
  2. on:{
  3. onDataRequest: function (id) {
  4.    webix.message("Getting children of " + id);
    
  5.      this.parse(
    
  6.      webix.ajax().get('api/fulltree/getChildrenOfNode?
    
  7. nodeId=’+id+’&nodeType=’+type).then(function(data) {
  8.              return data = data.json();
           })
    
    );
  9.    return false;
     }
    
    }

As you can see, on line 7, I will need to include a type reference to the API I have for returning the subdirectories. However, I am unable to do so since I can only use the ‘id’ parameter for onDataRequest. My website previously used a jstree and their function looked like “function(Node node)” and I could reference the id using “node.id” and the type as “node.type”.

My JSON looks like :
0:
id:“5b29972ae84a74665fb473ea”
“type”: “space”,
value:“vibhav”
webix_kids:false
1:
id:“5b2c0b83b64a35912886b207”
type:“collection”
value:“vibhav”
webix_kids:false
2:
id:“5b2b183bb64a7d2cad311baf”
type:“collection”
value:“lol”
webix_kids:false
3:
id:“5b2af7c0b64a7d2cad311b69”
type:“collection”
value:“knknnk”
webix_kids:true

How could I reference the ‘type’ in the API call.
Any help from the technical team will be greatly appreciated. I really want to use Webix.

Hello,

You can read any property of a tree node with the getItem method that can access a node by its id:

url:'api/fulltree/getChildrenOfNode?nodeType=root',
on:{
  onDataRequest: function (id) {
    var node = this.getItem(id);
    console.log(node); //log node object

    this.parse(
       webix.ajax().get(
          'api/fulltree/getChildrenOfNode?nodeId='+id+'&nodeType='+node.type
        ).then(function(data) {
          return data = data.json();
       })
     );
    return false;
  }
}