File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1- import { metaApi } from '$lib/api' ;
2-
31export const ssr = true ;
42export 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- }
You can’t perform that action at this time.
0 commit comments