use a function in action of auth modules in wizard module in vuex in vue


I have this function in auth.module.js:

  async [VERIFY_AUTH](context) {
if (JwtService.getToken()) {
  ApiService.setTokenAxios();
  return (
    ApiService.get("api/customer/me")
      .then(({ data }) => {
        console.log("auth request - useer:", data);
        context.commit(SET_AUTH, data);
      })
      ///////////
      .catch(({ response }) => {
        console.log(response);
        context.commit(SET_ERROR, serviceErrors(response.data));
      })
  );
} else {
  context.commit(PURGE_AUTH);
}

},

I want dispatch it in wizard.modules.js

  [SPOUSES](context, data) {
console.log(data);
return new Promise(() => {
  ApiService.post(`api/customer/${data.id}/spouses`, data.form).then(
    ({ data }) => {
      console.log(data);

      context.dispatch("auth/VERIFY_AUTH", null, { root: true });
    }
  );
});

},

I try it but it dont work
do you know what should I do?

Source: Vue – Stack Overflow

November 27, 2021
Category : News
Tags: action | dispatch | module | 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.