title: Onload method when the page is loading VUE
body: <p>I want to call the method when the page is loading. So far I call the method when I click, but when I try to use mounted to automatically call the method, it keeps failing, do you have some suggestion?</p>
  <p>Below is the code:</p>
  <pre><code>&lt;template&gt;
    &lt;div&gt;
      &lt;AppHeader&gt;&lt;/AppHeader&gt;
      &lt;div style=&quot;display: flex&quot;&gt;
        &lt;ul&gt;
          &lt;li
            style=&quot;cursor: pointer&quot;
            v-for=&quot;exchange of profileExchanges&quot;
            :key=&quot;exchange.id&quot;
            @click=&quot;getImagesByExchange(exchange.id)&quot;
          &gt;
            &lt;div style=&quot;padding: 20px; border: solid 2px red&quot;&gt;
              &lt;h3&gt;Brand: {{exchange.brand}}&lt;/h3&gt;
              &lt;p&gt;Description: {{exchange.description}}&lt;/p&gt;
              &lt;p&gt;Category: {{exchange.category}}&lt;/p&gt;
            &lt;/div&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
        &lt;div&gt;
          &lt;span style=&quot;margin: 10px&quot; v-for=&quot;url of exchangeImageUrls&quot; :key=&quot;url&quot;&gt;
            &lt;img width=&quot;250px&quot; :src=&quot;url&quot; /&gt;
          &lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;br /&gt;
    &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
  
  import AppHeader from '@/components/Header5'
  export default {
    components: {
      AppHeader
    },
    created() {
      this.$store.dispatch('exchange/getExchangesByProfile', this.$store.state.auth.user.profile.user)
    },
    data() {
      return {
        selectedExchangeId: '',
        exchanges: []
      }
    },
    computed: {
      user() {
        return this.$store.state.auth.user
      },
      profile() {
        return this.user.profile || {}
      },
      profileExchanges() {
        return this.$store.getters['exchange/profileExchanges']
      },
      exchangeImageUrls() {
        return this.$store.getters['exchange/imageUrls']
      }
    },
    methods: {
      getImagesByExchange(exchangeId) {
        this.$store.dispatch('exchange/getImagesByExchange', exchangeId)
      },
      getListings() {
  
      },
      updateProfile(profile, closeModal) {
        this.$store.dispatch('auth/updateProfile', profile)
          .then(_ =&gt; {
            closeModal()
          })
      }
    }   
  }
  
  &lt;/script&gt;
  </code></pre>
  <p>I try to put mounted like this</p>
  <pre><code>mounted: function() {
      this.getImagesByExchange() // Calls the method before page loads
  },
  </code></pre>
  <p>But it keeps failing. I guess the problem is how to access the key, but not sure.</p>