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

151
Visualizações
Cannot read string value of an object returned by params

I am just a beginner working on the note app which uses Laravel and Vue. And now I am having trouble trying to read the string value of an object returned by params from router.js and received by message inside props of MyIndex.vue. While the I think the object had been received, when alerting the user with toast, the "this.message.message" which is supposed to be the string value inside the object message is not readable by vue.

When I print out the "this.message" in toast, it alerts with [object Object]. But when I print out using "this.message.message" in toast, it do alert but without any message at all!

MyIndex.vue

import MyMaster from './Layout/MyMaster.vue';
import { useToast } from 'vue-toastification';
export default{
    name:'MyIndex',
    components: {MyMaster},
    props: { message: Object},
    created(){
        if(this.message){
            const toast = useToast();
            toast.info(this.message.message, {
                timeout: 2000,
            });
        }
    },
}

route.js

const ifAuth = (to, from, next) => {
const data = localStorage.getItem('auth');
if(data !== 'null'){
    const user = JSON.parse(data).user;
    return next({
        name:'index',
        params:{
            message: { type:'i', message: `${user.name} Already Logined!` }
        }
    })
}
return next();
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try to parse your json:

toast.info(JSON.parse(this.message).message), {
...
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