use dynamic urls

This commit is contained in:
csehviktor
2025-07-19 14:18:14 +02:00
parent 42298ff41b
commit 3e8def68db
4 changed files with 21 additions and 12 deletions
+9 -2
View File
@@ -20,8 +20,15 @@ export function getRealtimeData(): StatusMessage[] {
return realtimeData ?? [];
}
export async function getHistoricalData(url: string): Promise<StatusMessage[]> {
return await fetch(url)
export async function getHistoricalData(
agent: string,
period: string,
): Promise<StatusMessage[]> {
return await fetch(
import.meta.env.DEV
? `http://localhost:3000/agent/${agent}/${period}`
: `/agent/${agent}`,
)
.then((res) => res.json())
.then((data) => data as StatusMessage[]);
}