helper function

This commit is contained in:
Sam 2024-09-23 17:46:20 +01:00
parent ab37400522
commit 7253c40da1
1 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,16 @@
function queryConstructor(customFilters = {}) {
let filters = document.querySelectorAll(".filter");
let queryObject = {};
Object.assign(queryObject, customFilters);
filters.forEach((filter) => {
const filterId = filter.id;
const filterValue = filter.value;
queryObject[filterId] = filterValue;
});
let queryString = `query=${JSON.stringify(queryObject)}`;
return queryString;
}