Skip to content

Commit 6cd3bf4

Browse files
committed
Oops
1 parent d15e3cf commit 6cd3bf4

2 files changed

Lines changed: 24 additions & 25 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { metaApi } from '$lib/api';
2+
3+
export async function load({ setHeaders }): Promise<{ ok: false, error: string } | { ok: true, deviceCount: number }> {
4+
setHeaders({
5+
'cache-control': 'public, max-age=300'
6+
})
7+
8+
let deviceCount: number;
9+
10+
try {
11+
const { data } = await metaApi.publicGetOnlineDevicesStatistics();
12+
13+
deviceCount = data.devicesOnline;
14+
} catch (e) {
15+
console.error(e);
16+
17+
return {
18+
ok: false,
19+
error: 'Failed to fetch device count',
20+
};
21+
}
22+
23+
return { ok: true, deviceCount };
24+
}

src/routes/(anonymous)/+page.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,2 @@
1-
import { metaApi } from '$lib/api';
2-
31
export const ssr = true;
42
export const prerender = false;
5-
6-
export async function load({ setHeaders }): Promise<{ ok: false, error: string } | { ok: true, deviceCount: number }> {
7-
setHeaders({
8-
'cache-control': 'public, max-age=300'
9-
})
10-
11-
let deviceCount: number;
12-
13-
try {
14-
const { data } = await metaApi.publicGetOnlineDevicesStatistics();
15-
16-
deviceCount = data.devicesOnline;
17-
} catch (e) {
18-
console.error(e);
19-
20-
return {
21-
ok: false,
22-
error: 'Failed to fetch device count',
23-
};
24-
}
25-
26-
return { ok: true, deviceCount };
27-
}

0 commit comments

Comments
 (0)