Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

368
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda