3

I am new developer in VueJS and NodeJS development.

I am using apollo-boost,graphql,vue-apollo for front end section and I am using express-graphql, express, graphql, knex, MySQL for backend section.

After running the backend section, I am getting a proper response as below: Input parameter

{
  users {
    id,
    name,
    email
  }
}

Output:

{
  "data": {
    "users": [
      {
        "id": "1",
        "name": "test",
        "email": "test@test.com"
      },
      {
        "id": "2",
        "name": "test2",
        "email": "test2@test.com"
      }
    ]
  }
}

So I think the code is ok at a server side. Now I want to display those data in vuejs. I implemented the code as below:

<template lang="pug">
  div
    .home
      img(alt='Vue logo', src='../assets/logo.png')
    div(style="text-align: left; padding: 20px 60px")
      div getTodos: {{ users }}
      div(v-for="users in users")
        h4 {{ users.name }}
</template>

<script>
// @ is an alias to /src
import { gql } from 'apollo-boost';

export default {
  name: 'Home',
  components: {},
  apollo: {
    users: {
      query: gql`
        query {
          users {
            id
            name
            email
          }
        }
      `,
    },
  },
};
</script>

<style>
.w-100 {
  width: 100%;
}
</style>

I am not getting any errors but no any result to display in the front end section. Please let me know what's doing wrong?

Rohit Vyas
  • 790
  • 6
  • 16

0 Answers0