1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
"use client";
export async function downloadExport(): Promise<void> {
const res = await fetch("/api/export");
if (!res.ok) throw new Error(`Export failed: ${res.status}`);
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `export-${new Date().toISOString().slice(0, 10)}.json`;
document.body.appendChild(a);
a.click();
a.remove();
URL.revokeObjectURL(url);
}
|