Merge remote-tracking branch 'origin/21-add-functionality-for-listing-query-results-in-frontend' into 21-add-functionality-for-listing-query-results-in-frontend

This commit is contained in:
J-Klinke
2024-07-01 11:12:01 +02:00
2 changed files with 17 additions and 2 deletions

View File

@@ -198,7 +198,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) => {
for (let i = 0; i < data.length; i++) {
let category = data[i].toLowerCase();
category = category.charAt(0).toUpperCase() + category.slice(1);
document.getElementById("other-categories").appendChild(new Option(category));
}
});
}
window.onload = function () {
fetchCategories();
updateSections();
if (searchBar.value !== "") {
search(searchBar.value);