let xhr = new XMLHttpRequest();

xhr.open("GET", 'https://gitea.guams.fr/api/v1/repos/Guams/guams_homepage/commits?sha=main');
xhr.send();

xhr.onload = () => {
    if (xhr.status === 200) {
        let commits = JSON.parse(xhr.response);
        commits.forEach(commit => {
            const ul = document.getElementById("changelog-content");
            const li = document.createElement("li");
            const h2 = document.createElement("h2");
            const p = document.createElement("p");
            h2.innerText = new Date(commit.created).toLocaleDateString();
            p.innerText = commit.commit.message;
            li.appendChild(h2);
            li.appendChild(p);
            ul.appendChild(li);
        })
    }
}

xhr.onerror = function () {
    console.error("Network error with gitea");
};