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

432
Views
Get parameter from URL in Vue JS

I am working on SPA (Vue JS) and Laravel as API. I want when users will receive email to click on button that will sent them to specific route (already implemented).

So now i am struggling how to get the user id from the Vue JS part.

https://domain.test/admin/users/dashboard/user/65/show

65 from the URL is the user ID, so any idea how to extract that ID with java script from Vue JS?

I am not using vue router, this is Laravel route and Vue JS component is rendered from blade file.

I have implemented something like this bellow, but client refused...

https://domain.test/admin/users/dashboard/user/show?userId=65
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

let id = window.location.href.split('/').slice(-2)[0]
about 4 years ago · Juan Pablo Isaza Report

0

Since you're already rendering the page in a Blade file, you should already have access to the user ID server side.

In that case, simply add the variable server side. For example:

<a :href="'https://domain.test/admin/users/dashboard/user/' + {{ 
$user->id }} + '/show'">Go to Dashboard</a>
about 4 years ago · Juan Pablo Isaza Report

0

To get parmeters from url you can use vue router for that like this:

const routes = [
    // dynamic segments start with a colon
    { path: '/users/:id', component: User },
  ]

const User = {
  template: '<div>User {{ $route.params.id }}</div>',
}

Here is the link for more examples and vue router documentation:

https://router.vuejs.org/guide/essentials/dynamic-matching.html

You can also get parameters with only vanilla JavaScripe like follow:

const queryString = window.location.search;
console.log(queryString);
// ?product=shirt&color=blue&newuser&size=m

//then you have to parse the url
const urlParams = new URLSearchParams(queryString);

const color = urlParams.get('color')
console.log(color);
// blue
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!