Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template>
- <table class="table">
- <thead>
- <tr>
- <td>Name</td>
- <td>Email</td>
- </tr>
- </thead>
- <tbody>
- <tr v-for="user in users">
- <td>{{ user.name }}</td>
- <td>{{ user.email }}</td>
- </tr>
- </tbody>
- </table>
- </template>
- <script>
- export default {
- data() {
- return {
- users: [],
- }
- },
- created: function() {
- this.fetchUsers();
- },
- methods: {
- fetchUsers() {
- axios.get('/api/users').then((response) => {
- this.users = response.data;
- }).catch((error) => {
- console.log(error);
- })
- }
- }
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement