Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template>
  2.     <table class="table">
  3.         <thead>
  4.         <tr>
  5.             <td>Name</td>
  6.             <td>Email</td>
  7.         </tr>
  8.         </thead>
  9.         <tbody>
  10.         <tr v-for="user in users">
  11.             <td>{{ user.name }}</td>
  12.             <td>{{ user.email }}</td>
  13.         </tr>
  14.         </tbody>
  15.     </table>
  16. </template>
  17.  
  18. <script>
  19.     export default {
  20.         data() {
  21.             return {
  22.                 users: [],
  23.             }
  24.         },
  25.         created: function() {
  26.             this.fetchUsers();
  27.         },
  28.         methods: {
  29.             fetchUsers() {
  30.                 axios.get('/api/users').then((response) => {
  31.                     this.users = response.data;
  32.                 }).catch((error) => {
  33.                     console.log(error);
  34.                 })
  35.             }
  36.         }
  37.     }
  38. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement