Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
Remove query item from router

I'm using replace in vue to add query to the current url . and i assigned undefined if the value is not there.

this.$router.replace({
  name: "admin-frs",
  query: {
    limit: this.pageSize,
    page: this.currentPage,
    sort: this.sortbyapi || undefined,
    language: this.sortbyapiLang || undefined,
  },
})

this makes the query item disappear from the URL when the query data is getting updated which is fine.

it does not remove it from the query object.

any idea if there's a better approach than this?

plus is it possible to get the query as it is from the route? like &limit=10...etc

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If I understand correctly, the OP wishes to manipulate the query object passed to router.replace. It can be done with standard js.

Start by explicitly naming a query variable...

let query = $router.query;

To remove something, use js delete operator. For example, to remove query.limit...

// remove the limit
if (!this.pageSize) delete query.limit;

Or, if you're building that query, don't put limit in in the first place...

let query = {};
if (this.pageSize) query.limit = this.pageSize;
if (this.currentPage) query.page = this.currentPage;
// etc for the other properties
// query will now only have props for those selected above

Do any of these manipulations, then pass to the router referring to the variable...

$router.replace({ name: "admin-frs", query }); 

To restate as a string, there are probably several methods, including many in libraries you might have around, but natively...

let params = [];
for (let key in query)
  params.push(`${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`);
const queryString = params.join("&");
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!