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

283
Visualizações
Get json data to $router.push in Vue.js?

im new on js, and i try to create a router from my backend /user-info where are stored all informations from the current user :

enter image description here

Now, i wanted to find a mean to handle each information to use that on my Vuejs Dashboard, i used axios for that, so this is what i made for index.js:

const express = require('express')
const router = express.Router()
const { ensureAuth, ensureGuest } = require('../middleware/auth')
const axios = require('axios')


router.get('/user-info', ensureAuth, async (req, res) => {
   try {
     let uri = 'http://localhost:5000/user-info';
     res.json(`userInfo : ${req.user}`);
     this.axios.get(uri).then((response) => {
     this.$router.push({name:'Dashboard'});

   } catch (err) {
     console.error(err)
     res.render('error')
    }
 })

...and what i did for my Dashboard.vue :

<template>
  <div class="customers container">
  <h1 class="page-header">Welcome to your dashboard</h1>
  <table class="table table-striped">
   <thead>
    <tr>
     <td>{{user.image}}</td>
     <td>{{'Hello' user.displayName}}</td>
     <<td>{{user.email}}</td>
     <th></th>
    </tr>
   </thead>
 </table>

</div>
</template>
<script>
export default {
name: 'dashboard',
data () {
return {
    user: [],

  }
},

methods: {
getUserInfo(){
  this.$http.get('http:localhost:5000/user-info')
    .then(function(response){

    this.user = (response.body); 
   });
  }
 </script>

Unfortunately i got nodemon :

[nodemon] app crashed - waiting for file changes before starting...

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