I’m having an Error in Mounted hook (Promise/Async) in my Vue js App


ive setup my Vuex store and modules with all endpoints declared in my actions and connected to the getters too.

but my app returns this error compilation.

Help me check what might be wrong.

...mapActions('codes', [
      'fetchCode',
      'fetchCodes',
      'updateCode',
      'selectCode',
      'setSelectAllState'
  ]),

  async fetchData({page, sort}) {
    let data = {

      name: this.filters.name ? this.filters.name : null,

        from_date:
          this.filters.from_date === ''
            ? this.filters.from_date
            : this.filters.from_date,

        to_date:
          this.filters.to_date === ''
            ? this.filters.to_date
            : this.filters.to_date,

        orderByField: sort.fieldName || 'created_at',

        orderBy: sort.order || 'desc',
        page,
    }

    this.isRequestOngoing = true
    let response = await this.fetchCodes(data)
    this.isRequestOngoing = false

  

  return {
    
    data: response.data.result.data,

  }    
  },

It only returns this error in my browser console

[Vue warn]: Error in mounted hook (Promise/async): "TypeError: Cannot
read properties of undefined (reading ‘page’)"

I’ve googled the hell out of this error, checked my api numerous times.. šŸ™

Source: JavaSript – Stack Overflow

November 28, 2021
Category : News
Tags: javascript | promise | typescript | Vue.js | vuex

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.