MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / fetchVersions

Function fetchVersions

client/src/pages/status/version.tsx:19–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17
18 useEffect(() => {
19 const fetchVersions = async () => {
20 const clientVersion = getVersionObject();
21
22 let apiVersion = { version: 'unknown', error: '' };
23 try {
24 const response = await fetch(`${envData.apiLocation}/status/version`);
25 if (response.ok) {
26 apiVersion = (await response.json()) as {
27 version: string;
28 error: string;
29 };
30 } else {
31 apiVersion.error = `HTTP ${response.status}`;
32 }
33 } catch (error) {
34 apiVersion.error =
35 error instanceof Error ? error.message : 'Failed to fetch';
36 }
37
38 setVersionData({
39 client: clientVersion,
40 api: apiVersion
41 });
42 };
43
44 void fetchVersions();
45 }, []);

Callers 1

VersionEndpointFunction · 0.85

Calls 1

getVersionObjectFunction · 0.90

Tested by

no test coverage detected