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

363
Views
Vue JS Syntax error: "Unexpected Token, expected ,

I am working on a Django aplication that has VueJS in it. I am new to Django and even newer to VueJS.

I am getting this error when I try to run my code:

ERROR Failed to compile with 1 errors
2:11:51 PM

error in ./src/router/index.js

Syntax Error: Unexpected token, expected , (51:0)

49 | } 50 |

51 | }) | ^ 52 | 53 | export default router 54 |

@ ./src/main.js 5:0-30 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

here is my router/index.js file contents:

import Vue from 'vue'
import Router from 'vue-router'
import Chat from '@/components/Chat'
import UserAuth from '@/components/UserAuth'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/chats',
      name: 'Chat',
      component: Chat
    },

    {
      path: '/auth',
      name: 'UserAuth',
      component: UserAuth
    }
  ]
})

router.beforeEach((to, from, next) => {
  if (sessionStorage.getItem('authToken') !== null || to.path === '/auth') {
    next()
    }

  else {
    next('/auth')
    }

  }

})

export default router

What is the reason for the syntax error and how do I correct it?

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

0

Check the extra bracket you have in:

router.beforeEach((to, from, next) => {
  if (sessionStorage.getItem('authToken') !== null || to.path === '/auth') {
    next()
    }

  else {
    next('/auth')
    }
  }   <-----------
})

Please remove it, one tip use code editors, most of them will indicate this silly mistakes that you may not realize.

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!