17 lines
408 B
JavaScript
17 lines
408 B
JavaScript
|
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;
|
||
|
}
|