implemented fetching categories from backend
This commit is contained in:
parent
4e645903e3
commit
d9707a25df
@ -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 () {
|
window.onload = function () {
|
||||||
|
fetchCategories();
|
||||||
updateSections();
|
updateSections();
|
||||||
if (searchBar.value !== "") {
|
if (searchBar.value !== "") {
|
||||||
search(searchBar.value);
|
search(searchBar.value);
|
||||||
|
@ -52,8 +52,7 @@
|
|||||||
<option>Dataset</option>
|
<option>Dataset</option>
|
||||||
<option>API</option>
|
<option>API</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<optgroup label="Other categories">
|
<optgroup id="other-categories" label="Other categories">
|
||||||
<option>a category</option>
|
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
<input type="search" name="query" id="search-entry" placeholder="Search">
|
<input type="search" name="query" id="search-entry" placeholder="Search">
|
||||||
|
Loading…
Reference in New Issue
Block a user