API Client Examples
Fetch Example
async function getMetrics() {
const res = await fetch('/metrics');
if (!res.ok) throw new Error('Failed to fetch metrics');
return await res.text();
}
Axios with Retry
import axios from 'axios';
import axiosRetry from 'axios-retry';
const client = axios.create({ baseURL: process.env.NEXT_PUBLIC_API_BASE_URL });
axiosRetry(client, { retries: 3, retryDelay: axiosRetry.exponentialDelay });
export async function getProvidersHealth() {
const { data } = await client.get('/providers/health');
return data;
}