Updated UI
This commit is contained in:
@@ -2,6 +2,14 @@ export const BASE = import.meta.env.DEV ? 'http://10.69.5.23:3000' : ''
|
||||
|
||||
export type DataRow = Record<string, number | string | null>
|
||||
|
||||
export async function fetchDaily(start?: string, end?: string): Promise<DataRow[]> {
|
||||
const params = new URLSearchParams()
|
||||
if (start) params.set('start', start)
|
||||
if (end) params.set('end', end)
|
||||
const res = await fetch(`/api/daily?${params}`)
|
||||
return res.json()
|
||||
}
|
||||
|
||||
async function get<T>(path: string, params: Record<string, string> = {}): Promise<T> {
|
||||
const url = new URL(`${BASE}${path}`, window.location.origin)
|
||||
Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v))
|
||||
|
||||
Reference in New Issue
Block a user