implemented fetching categories from backend

This commit is contained in:
J-Klinke 2024-07-01 10:21:43 +02:00
parent 4e645903e3
commit d9707a25df
2 changed files with 17 additions and 2 deletions

View File

@ -166,7 +166,23 @@ function updateSections() {
}
}
// fetches the further categories used in the filter function
function fetchCategories() {
const fetchURL = new URL(
"api/v1/categories" , baseURL);
fetch(fetchURL)
.then(resp => resp.json())
.then((data) => {
console.log(data); // TODO remove
for (let i = 0; i < data.length; i++) {
console.log(data[i]); // TODO remove
document.getElementById("other-categories").appendChild(new Option(data[i]));
}
});
}
window.onload = function () {
fetchCategories();
updateSections();
if (searchBar.value !== "") {
search(searchBar.value);

View File

@ -52,8 +52,7 @@
<option>Dataset</option>
<option>API</option>
</optgroup>
<optgroup label="Other categories">
<option>a category</option>
<optgroup id="other-categories" label="Other categories">
</optgroup>
</select>
<input type="search" name="query" id="search-entry" placeholder="Search">