Expand my Community achievements bar.

CQ.Util.formatData(CQ.Util.eval('/apps/

Avatar

Level 4

Unable to read json file using CQ.Util.formatData(CQ.Util.eval('/apps/ax.json')  in 6.4.IT is working in other instance.Any js files need to be installed or any config changes needed

2 Replies

Avatar

Community Advisor

Hi, 


There might be missing clientlibs required for those functions to work. In any case, is there anything preventing you from using vanilla JS to achieve the same result? Using vanilla JS is preferable, so something like this should work:

 

fetch('/apps/ax.json')
  .then(response => response.json())
  .then(data => {
    //TODO: You can write your own "formData" function to parse the date in any format
    const formattedData = formatData(data);
    console.log(formattedData); 
  })
  .catch(error => {
    console.error('Error:', error);
  });

//TODO
function formatData(data) {
...
  return data;
}

 

Hope this helps



Esteban Bustamante

Avatar

Administrator

@Shakthi1 Did you find the suggestion helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!



Kautuk Sahni