I want to show dashboard data for following json:
/api/company/:companyId/campaign/analytics -> {
pending: 30,
processed: 10
}
/api/company/:companyId/users/analytics -> {
activeUsers: 10
}
/api/company/:companyId/templates/analytics -> {
approvedTemplates: 20,
pendingTemplates: 10,
rejectedTemplate: 10
}
I'll create a dashboard to display this data. Let me build a clean, responsive dashboard that fetches and displays analytics from these three endpoints.
I've created a clean, responsive analytics dashboard that fetches and displays data from your three API endpoints. The dashboard is organized into three sections:
The dashboard automatically fetches data from your API endpoints and refreshes every 5 minutes (configurable). Each card displays the relevant metric with an appropriate icon and description.
To use this dashboard, simply navigate to /dashboard/{companyId} where {companyId} is the ID of the company you want to view analytics for.
The error indicates that the API endpoints are returning HTML (likely a 404 page) instead of JSON. Let me fix this by creating mock API endpoints and updating the dashboard to handle errors properly.
I've fixed the error by:
The dashboard now works with /dashboard/123 (or any company ID) and displays the mock analytics data. The API endpoints simulate the exact JSON structure you specified:
{ pending: 30, processed: 10 }{ activeUsers: 10 }{ approvedTemplates: 20, pendingTemplates: 10, rejectedTemplate: 10 }You can now replace these mock API endpoints with your actual backend endpoints when ready.
Please make sure to add the following environment variable to your project: