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

206
Vistas
TypeError: Cannot read properties of undefined (reading 'token')

when i use localStorage i have this error : Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'token'). But my token is here :

enter image description here

Promise is here :

enter image description here

        async loginSubmit () {
        const response = axios.post('http://localhost:3000/api/auth/login', {
            email: this.email,
            password: this.password
        });
        localStorage.setItem('token', response.data.token);
        console.log(response);
        this.$router.push('actu');

    },

Can you help me ? please

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Axios returns a promise, you need to await the request:

const response = await axios.post(...)
about 4 years ago · Juan Pablo Isaza Denunciar

0

You are using axios, it returns a promise. That's why you have this error. You have to use async await to wait for axios to respond

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