Frontend API & Integration
This document explains how the Next.js frontend interacts with the backend API.
Communication Flow
- API Calls: The frontend makes REST API calls to the backend to retrieve client data.
- WebSocket Integration: For real-time updates, the frontend uses WebSocket connections.
- Error Handling: In case of API errors, the frontend shows appropriate error messages.
Example Code Snippet
// Example: Fetching client data in Next.js
async function fetchClients() {
const res = await fetch(`${process.env.API_ENDPOINT}/clients`);
const data = await res.json();
return data;
}
Ensure that the API_ENDPOINT
variable in your .env
file is correctly set.