mathmari
Gold Member
MHB
- 4,984
- 7
I had tried the following :
I want to display all the DisplayNames. First I did it with many for loops and it worked, now I am trying to write it with less code by setting dataObj.Nodes into the current dataObj. Is this correct so far?
Can the result be also in a TreeView (TreeItem) ?
JavaScript:
const [dataObj, setDataObj] = useState([]);
useEffect(() => {
fetch('https://giant-db-connection.onrender.com/opc_ua_tree/')
.then((res) => res.json())
.then((data) => {
setDataObj(data[0]['tree_structure'][0].Nodes[0]);
console.log(dataObj.DisplayName);
while (dataObj.Nodes) {
for (let i = 0; i < dataObj.Nodes.length; i++) {
console.log(dataObj.Nodes[i].DisplayName);
}
setDataObj(dataObj.Nodes);
}
});
}, []);
Can the result be also in a TreeView (TreeItem) ?