25 Sep 2024 09:54 AM
I am developing a Custum App and app function in dynatrace to retrieve data from an API, and I would like to visualize this data using DataTable/DataTableV2. However, I am encountering some issues in the process.
I appreciate your help by providing a solution or giving me example code for the same.
Solved! Go to Solution.
25 Sep 2024 01:03 PM
Hello @zaid-bashir,
We have a step-by-step tutorial for API data fetching, putting the data into a DataTable component and more here in the Dynatrace Developer Portal.
For us to be able to help you with your exact problem, please share the related code and error messages.
All the best,
Stefan
26 Sep 2024 06:55 AM
Hello @StefanKern
For Your Reference, Please Find The Code In An Image Below.
I Am Getting Some JSON Parsing Error and sometimes blank Page.
Can You Help Me By Providing Code Snippet Related To This Issue. For Your Information I Am Accessing AuditLogs.
26 Sep 2024 02:57 PM
It seems like you have syntax error in the code.
You should use the curly braces around `result.data` and `</DataTable/>` as following:
{result.data && (
<DataTable data={auditLogsData} columns={convertToColumns(auditLogsData)}>
</DataTable/>
)}
01 Oct 2024 11:18 AM
Thanku For The Update.
But I am still facing issue.
If Possible Then You Can Forward Your Working Version (Audit Logs)
PFA AuditLogs JSX File and App Function File
03 Oct 2024 10:44 AM - edited 03 Oct 2024 10:47 AM
Hi @zaid-bashir ,
Not Sure if you found a solution for this yet but can you just paste your error here?
Sometimes all you have to do is do JSON.stringify(data) in the code and then in the DataTable use JSON.parse(data). This ensures that all the JSON data is properly organised with proper formatting.
In your case all you have to do is change these two steps.
const auditLogsData = JSON.stringify(result);
Then in DataTable you change data={JSON.parse(auditLogsData)}
01 Oct 2024 07:48 AM
Hi @zaid-bashir
Let us know if the above solution works for you, if so, please 'accept as solution'.
Thanks, PEnny