Hi, having trouble loading data into my tree view and would be grateful for help.
My model is getData.js and includes these lines:
//getData.js
async function getAssets() {
securityToken = await getToken();
var url = “http://dashboard.myserver.com:8080/api/customer/abc123/devices?limit=100”;
var response = await axios.get(url, { headers: { “X-Authorization”: "Bearer " + securityToken }, });
return response.data.data
}
export { getAssets }
My view is test_tree.js and includes these lines in init():
//test_tree.js
this.loadData = function() {
var customerData = getAssets();
this.$$(“hierarchyTree”).parse(customerData);
Problem is, when I call getAssets(), it only returns a Promise, never the actual data. I’ve also tried getAssets().then(function(customerData) {this.$$(“hierarchyTree”).parse(customerData)}) but that produces a promise rejection, and a “TypeError: Cannot read property ‘$$’ of undefined”.