AstroCom-API/public/assets/js/directory.js

17 lines
518 B
JavaScript

function getDirectoryEntries() {
fetch('/api/v1/directory')
.then(response => response.json())
.then(data => {
const table = document.getElementById('directoryList');
data.forEach(entry => {
const row = document.createElement('tr');
row.innerHTML = `<td>${entry.number}</td><td>${entry.name}</td>`;
table.appendChild(row);
});
})
.catch(error => console.error('Error fetching directory:', error));
}
document.addEventListener('DOMContentLoaded', function () {
getDirectoryEntries();
});