MCPcopy
hub / github.com/slowlydev/f1-dash / fetchMap

Function fetchMap

dashboard/src/lib/fetchMap.ts:3–21  ·  view source on GitHub ↗
(circuitKey: number)

Source from the content-addressed store, hash-verified

1import type { Map } from "@/types/map.type";
2
3export const fetchMap = async (circuitKey: number): Promise<Map | null> => {
4 try {
5 const year = new Date().getFullYear();
6
7 const mapRequest = await fetch(`https://api.multiviewer.app/api/v1/circuits/${circuitKey}/${year}`, {
8 next: { revalidate: 60 * 60 * 2 },
9 });
10
11 if (!mapRequest.ok) {
12 console.error("Failed to fetch map", mapRequest);
13 return null;
14 }
15
16 return mapRequest.json();
17 } catch (error) {
18 console.error("Failed to fetch map", error);
19 return null;
20 }
21};

Callers 1

MapFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected