[Vuejs]-Debounce Vuex Action Call to Database Not Working

0👍

You need to return a promise from your action. Returning a promise of undefined (which is what is currently happening) resolves immediately.

dateSelected(context, data) {
  return new Promise(resolve => {
    getCalendarData(isBetween.date, context.rootState.userId)
    .then(result => {
      context.commit('SET_MONTHLY_DATA', { result: result.Result, basedOn: isBetween.date });
      resolve();
    }
  }
},

Additionally, a vuex commit does not return a promise, so it doesn’t make sense to await it.

Leave a comment