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

245
Views
How to handle login JWT token in Vue JS?

I have a token in my localstorage. if I delete the token in localstorage, then I'm not logging out. Can you suggest me example how to do it.

created() {
  if (this.vueToken) {
  let headers = {
    Authorization: "Bearer " + localStorage.getItem("vueToken"),
  };

  axios
    .get("checkLogin", {
      headers: headers,
    })
    .then((response) => response);
}else{
    this.$router.push('/login')
}
  },
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You have to set up a condition in your secure routes, for example, if token is null in your localstorage then you will push it to local storage. Here is an example code.

mounted() {
this.token = localStorage.getItem("ivToken");    
if(this.token===null){     
  this.$router.push("/signin")
}

},`

over 4 years ago · Santiago Trujillo 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!