use api endpoint
This commit is contained in:
parent
750a918599
commit
cf17e628b3
1 changed files with 5 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
const fetch = require('node-fetch');
|
||||
|
||||
// URL of the repo
|
||||
const repoURL = 'https://git.kennel.ml/Anri/Constnium/raw/branch/main/README.md';
|
||||
const repoURL = 'https://git.kennel.ml/api/v1/repos/Anri/Constnium/contents/README.md';
|
||||
|
||||
// Store the data from the repo
|
||||
let data = null;
|
||||
|
@ -15,10 +15,11 @@ async function get() {
|
|||
// If data is older than one day, refresh it
|
||||
if (Math.ceil(Math.abs(now - timestamp) / (1000 * 3600 * 24)) > 2 || data === null) {
|
||||
await fetch(repoURL)
|
||||
.then(res => {
|
||||
data = res.text();
|
||||
.then(res => res.json().then(json => {
|
||||
// eslint-disable-next-line no-undef
|
||||
data = Buffer.from(json.content, json.encoding).toString('utf8');
|
||||
timestamp = now;
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
return data;
|
||||
|
|
Loading…
Reference in a new issue