-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathLatestDocsVersion
More file actions
35 lines (30 loc) · 894 Bytes
/
LatestDocsVersion
File metadata and controls
35 lines (30 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React, { useEffect, useState } from 'react';
const LatestDocsVersion = () => {
const [version, setVersion] = useState('Loading...');
useEffect(() => {
const url = 'https://api.github.com/repos/lavanet/docs/releases/latest';
fetch(url, {
headers: {
'Accept': 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28',
},
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
setVersion(data.tag_name);
})
.catch(error => {
console.error('Error fetching version:', error);
setVersion('Failed to load version');
});
}, []);
return (
<span>{version}</span> // Wrapped in a span for potential styling or semantic purposes
);
};
export default LatestDocsVersion;