Clear query string Hi, can anyone assist me clearing query strings when it's empty? I'm doing search and when the input is empty I want the query string to be removed, but at the moment it's like this: ?leita=
Here is what I have:
Index.vue
search: throttle(function (value) {
this.$inertia.get('/bloggið', {leita: value}, {
preserveState: true,
replace: true
});
}, 500)
If there were multiple key/values in the object I would suggest:
Object.entries(obj).reduce((a,[k,v]) => (v ? (a[k]=v, a) : a), {})
However, since there is only one:
search: throttle(function (value) {
this.$inertia.get('/bloggið', (value ? {leita: value} : {}), {
preserveState: true,
replace: true
});
}, 500)
@tykus - Thanks for this. Do you have idea of how I can create a method to clear the query string?
Please sign in or create an account to participate in this conversation.