i need remove or hidden query params when i filter data.
this my code
const filterCategory = useForm({ categories: "" });
const filterUnit = useForm({ unit: "" });
watch(
() => filterCategory.categories,
() => {
const params = { categories: filterCategory.categories };
filterCategory.get(route("products.index", params), {
preserveScroll: true,
onStart: () => rmQueryParams(),
onSuccess: () => rmQueryParams(),
});
}
);
watch(
() => filterUnit.unit,
() => {
const params = { unit: filterUnit.unit };
filterUnit.get(route("products.index", params), {
preserveScroll: true,
onBefore: () => rmQueryParams(),
onProgress: () => rmQueryParams(),
onSuccess: () => rmQueryParams(),
});
}
);
content of the function rmQueryParams()
export const rmQueryParams = () => {
window.history.replaceState(
{},
document.title,
window.location.pathname,
window.location.search
);
};
- before
http://blog.zik/products?categories=9bfbca82-3cba-43b8-be60-759d8736c085 - after
http://blog.zik/products
New contributor
Freya Premium is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.