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

211
Views
Autenticación Vuejs JWT VUEX

Hola, realizo la autenticación vue con jwt y vuex, y funciona bien, pero necesito cargar el token y el usuario cuando actualizo la página. encuentro en línea este código store.dispatch('auth/attemptAuthtoken', localStorage.getItem('authToken')) y funciona bien pero solo funciona en main.js. Necesito ponerlo en index.js (archivo principal de la tienda), pero si lo uso, tengo un problema con la tienda/despacho, etc.
Intento importar la tienda pero también tengo un problema.
ingrese la descripción de la imagen aquí ingrese la descripción de la imagen aquí
Alguien me puede ayudar a arreglarlo? (Empecé hace muy poco a usar vue/vuex)
principal.js

 import { createApp } from 'vue' import App from './App.vue' import router from './router' import axios from 'axios' import store from './store' store.dispatch('auth/attemptAuthtoken', localStorage.getItem('authToken')) store.dispatch('auth/attemptUser', JSON.parse (localStorage.getItem('user'))) axios.defaults.baseURL = 'https://**********/' createApp(App).use(store).use(router).mount('#app')

índice.js

 import { createStore } from 'vuex' import auth from './auth.js' export default createStore({ state: { }, mutations: { }, actions: { }, modules: { auth } })

about 4 years ago · Juan Pablo Isaza
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!