[Vuejs]-Nuxt fetch hook api can't access the api folder

0👍

your store is and should be a global construct of your application.
it means when you call for a action and your setup is correct, you don’t have to handle directives/folders by yourself.

in your case all you should do is dispatch the action in your component like this:

async fetch() {
    const { store, error } = this.$nuxt.context;
    try {
      await store.dispatch("apiOne", null, { root: true });
    } catch (e) {
      error({
        message: "error"
      });
    }
  }

Leave a comment