[Vuejs]-Vuejs loop over in data results not on how many fields i have

0👍

Your users inside Data looks wrong.
Here is an edited version

Profile

<script>
  import UserProfile from '../partials/UserProfile.vue'
  import User from '../models/User'
  import Form from '../core/Form'

  export default {
      components: {
        UserProfile
      },
      data() {
        return {
            users: [ 
              {
                name: 'FirstName LastName',
                email: 'firstname.lastname@gmail.com'
              }
            ],
        }
      },
      created() {
        // User.all(users => this.users = users)
      }
  };
</script>

0👍

Since you’re only returning the currently logged in user, you’ll have to edit your Profile component a bit:

<template>
    <div>
        <h3>Profile</h3>
        <user-profile :user="user" :key="user.id"></user-profile>
    </div>
</template>

<script>
    import UserProfile from '../partials/UserProfile.vue'
    import User from '../models/User'
    import Form from '../core/Form'

    export default {
        components: {
            UserProfile
        },
        data() {
            return {
                user: {},
            }
        },
        created() {
            axios.get('/user/profile').then(res => this.user = res);
        }
    };
</script>

Leave a comment