Vue combined with modules for namespace management

I seem to be facing a problem that I thought I had solved before by using namespaces, but unfortunately nothing seems to be working. Here's my module:

const Algo1Module = {
  namespaced: true,
  state: {
    questions: {
      question1: "test",
      question2: "",
      question3: "",
      question4: "",
      question5: "",
      question6: ""
    }
  },
  getters: {
    getMyQuestions(state) {
      return state.questions;
    }
  }
};

export default Algo1Module; // exporting the module

This is the content of my index.js file in the store directory:

import Vuex from "vuex";
import createLogger from "vuex/dist/logger";
import algo1 from "@/store/modules/algo1.store";

Vue.use(Vuex);
const debug = process.env.NODE_ENV !== "production";

export default new Vuex.Store({
  modules: {
    algo1
  },
  strict: debug,
  plugins: debug ? [createLogger()] : []
});

I'm trying to access my getters from my component like this:

<script>
import { mapGetters } from "vuex";
export default {
  name: "Algo",
  computed: {
    ...mapGetters("Algo1Module", ["getMyQuestions"])
  }
};
</script> 

However, I keep receiving an error message in the console: [vuex] module namespace not found in mapGetters(): Algo1Module/

I'm quite confused and unsure where I might have gone wrong. Any help or guidance would be greatly appreciated.

Answer №1

Enter the name you specified when importing the module, such as algo1

Answer №2

  1. The name of your module is currently registered under the algo1 name.
  2. If you prefer to call it Algo1Module, then make sure to register it in the store as shown below:
modules: {
  Algo1Module: algo1,
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Passing Parameters Using Axios in Vue.js

Currently, I am utilizing Axios within VueJS to make ajax requests. However, I have encountered an issue when attempting to send these requests. This snippet shows my JavaScript code: axios.post('http://localhost/app/php/search.php', { quer ...

Is it possible to nest axios post requests within another axios post request?

Can someone assist me with getting the session ID from the API to utilize it as a part of my input for an Axios POST request in order to retrieve user information? Despite double-checking my code thoroughly, I keep encountering a session expired error. Any ...

"Embracing Micro-frontends: Building dynamic web applications using a variety of frontend

I am currently facing a software architecture dilemma. My extensive monolithic web application is built using PHP and backbone js, but I am eager to integrate a new front-end framework like react/vue. The question arises about the best approach to tackle t ...

Send the id of the chosen row to the Component tag within the blade file

I'm working on passing the id of the currently selected row within a for loop when it's clicked on. The goal is to then pass that id to a Vue component. In my index.blade file: @foreach($cats as $cat) <tr> <td class="catme" d ...

Having trouble receiving responses from pusher when attempting to utilize private channels, without any error notifications being displayed

While utilizing a public channel, I receive the responses without any issue. However, when I switch to a private channel and the channels.php check returns true, I am not receiving any response. According to Pusher's logs, the message is being success ...

Here is a unique rewrite: "Strategies for effectively passing the data variable in the geturldata function within Vue.js on the HTML side vary

How can I properly pass a variable in the getdataurl function in Vue.js? I need help with passing a variable in getdataurl function in Vue.js. Please provide a clear explanation and include as much detail as possible. I have tried doing some background r ...

Encountered an error: Vue is not recognized within Laravel environment

While working on a Laravel application with Vue 3, I encountered an issue. When trying to load the welcome.blade.php file, I couldn't see the Vue file content and received the following error in the console: Uncaught ReferenceError: Vue is not defined ...

The Safari browser is currently having trouble loading the data sent back from the server

After successfully developing and deploying my website carspeedyrental.com, I received reports from some clients indicating that the website does not display available cars on the iPhone Safari browser. Interestingly, when tested on various browsers on A ...

The Vuejs code functions properly in the overall application, but is not functioning within the specific component

Before, my Vue.js app worked flawlessly until I tried putting it into a Vue component. It started throwing the following error: [Vue warn]: Error compiling template. Here's the code for the component (components.php): <script> Vue.component(&ap ...

Having an issue with my Vue page where it is attempting to send a request twice. My tech stack includes inertia, Laravel, and

<template> <app-layout title="Dashboard"> <template #header> <h2 class="h4 font-weight-bold">Create</h2> </template> <div class="container mt-5 text-gray-300"> ...

Enhancing Efficiency with Laravel 5: Updating Multiple Data Entries

My Simple Todo App lacks the ability to persist multiple record updates simultaneously. The client-side version can be found here: http://codepen.io/anon/pen/bVVpyN Whenever I perform an action, I send an HTTP request to my Laravel API for data persistenc ...

Download an image file directly from an HTTP response in Laravel using Vue, Axios, and Intervention Image

Currently, I am in the process of setting up a media asset database by utilizing Laravel, Vue, Axios, and Intervention image. One of my main objectives is to allow the user to specify their desired image height and width before proceeding with the download ...

Uploading large files on Vuejs causes the browser to crash

Whenever I try to upload a file using my browser (Chrome), everything goes smoothly for files with a size of 30mb. However, if I attempt to upload a file that is 150mb in size, the browser crashes. The server's maximum upload size has been configured ...

Creating an Interactive Form with Laravel and Vue.js to Store and Modify Database Entries

Can someone help me with creating a simple input box that fetches the default value from a database and updates the database when the user changes the value? I am working on a project using Laravel 5.5 and Vue components. The initial value should be retrie ...

Using PHP to submit a file through an API

I'm currently working on creating an API endpoint to integrate with my Laravel and Vue application. public function avatar(Request $request) { $user = User::find(Auth::id()); $validator = Validator::make($request->all(), [ ...

Instructions for showcasing a 404 error page in the event that a back-end GET request to an API fails due to the absence of a user. This guide will detail the process of separating the

I am currently working on an application that combines JavaScript with Vue.js on the front-end and PHP with Laravel on the back-end. When a GET request is made from the front-end to the back-end at URL /getSummoner/{summonerName}, another GET request is t ...

Learn the technique of looping through multiple HTML elements and wrapping them in Vue.js easily!

i need to wrap 2 HTML elements together Here is my code snippet using Vue.js <tr> <th v-for="(item9,index) in product_all" :key="item9.id"><center>Qty</center></th> <th v-for="(item99,index) in product_all" :key=" ...

Mastering Array Dispatch in VueJS

I've encountered an issue while trying to send an array of data to the backend. I attempted to include [] in the dispatch variables and on the backend, but it only captures the last data sent to the backend. My objective is to associate each data with ...

Unable to verify identity using spa

My API is running on the URL: https://example.com, and my vue.js app is running on: https://app.example.com. I have configured the .env file as follows: SESSION_DOMAIN=.example.com SANCTUM_STATEFUL_DOMAINS=https://app.example.com The axios configuration i ...

Issue with Laravel Vue search-dropdown and other components failing to render correctly for certain users

We are currently implementing a searchable dropdown menu for our web application using a vue component. Strangely, the component fails to load on my local version (xampp) as well as on the deployed website. However, it displays properly on another develope ...