Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
I keep getting this error in my console everything i visit this route
    VM28353:1 Uncaught (in promise) SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at getUser (auth.js?c7d4:11)
    at wrappedGetter (vuex.esm-browser.js?5502:335)
    at Object.eval [as getUser] (vuex.esm-browser.js?5502:88)
    at Object.get [as getUser] (vuex.esm-browser.js?5502:135)
    at Proxy.getuser (Profile.vue?c66d:98)
    at ReactiveEffect.run (reactivity.esm-bundler.js?a1e9:160)
    at ComputedRefImpl.get value [as value] (reactivity.esm-bundler.js?a1e9:1086)
    at Object.get [as getuser] (runtime-core.esm-bundler.js?5c40:2109)
    at Proxy.render (Profile.vue?c66d:26)

Profile.vue This is the only file that calls the getters

computed: {
       getuser() {
        return this.$store.getters.getUser;
       },
     },

    

Auth.js In the console its state that the error is coming from my getUser getters in my auth module

    const getters = {
       isLoggedIn: (state) => !!state.token,
       getUser: (state) => JSON.parse(state.user),
       getToken: (state) => state.token,
    };

    const mutations = {
      setToken: (state, payload) => {
        state.token = payload;
        localStorage.setItem("auth_token", payload);
      },
      setUser: (state, payload) => {
        state.user = payload;
        localStorage.setItem("user", JSON.stringify(payload));
      },
    };
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I guess the state.user is already a object therefore you don't need to use JSON.parse since JSON.parse() converts the input into a string. The toString() method of JavaScript objects by default returns [object Object], resulting in the observed behavior.

Try removing that such that your code should be

const getters = {
       isLoggedIn: (state) => !!state.token,
       getUser: (state) => state.user,
       getToken: (state) => state.token,
    };
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda