There was an error thrown: [vuex] getters must be defined as a function, however, the getter "getters.default" is an empty

After building my VUE project for production with NPM, I encountered an error in the console. Can anyone shed some light on why vuex is presenting this complaint? npm 3.10 , node.js 8.11

Uncaught Error: [vuex] getters should be function but "getters.default" is {}.
at assert (vuex.esm.js:97)
at vuex.esm.js:271
at vuex.esm.js:85
at Array.forEach (<anonymous>)
at forEachValue (vuex.esm.js:85)
at vuex.esm.js:270
at Array.forEach (<anonymous>)
at assertRawModule (vuex.esm.js:265)
at ModuleCollection.register (vuex.esm.js:191)
at new ModuleCollection (vuex.esm.js:165)

Your assistance is appreciated. Tonathiu

Answer №1

Assuming you have a getter function within the vuex getters and attempting to call it using this method:

store.getters.default()

This approach is incorrect and will result in error logs.

The proper way to do this is by utilizing vuex's mapGetters within the computed property of the vue component, as shown below:

import { mapGetters } from 'vuex'
...
...
computed:{
    ...mapGetters(['default'])
},
...
...

Then proceed to call the default getter using `this` (the vm instance) like so:

this.default()

That should resolve the issue.

I trust that this explanation is helpful.

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

AJAX response from open cart is returning null JSON data

Hey there, I'm having a problem with my ajax request. It seems like I keep receiving a null value for json. Let me show you the JavaScript code... <script> $(document).ready( function() { $('#donate-box-submit').on('click' ...

Tips on toggling the visibility of div elements with JavaScript

In my selection block, I have three categories of elements and associated Divs. The goal is to display the related divs when a category is selected, while keeping them hidden otherwise. Specifically, I want the husband_name and number_pregnancy divs to be ...

Enable or disable options with the user's permission

Currently, I am developing a WordPress plugin that will display a simple div on all pages. The code is set up to create the div, turn it into a shortcode, and then show it on each page. I want to include a checkbox in the admin settings so that users can ...

Extracting numbers using regular expressions can be tricky especially when dealing with mixed

Currently, I am attempting to create a javascript regex that can extract decimal numbers from a string containing a mix of characters. Here are some examples of the mixed strings: mixed string123,456,00indeed mixed string123,456.00indeed mixed string123,4 ...

Is a postcss.config.js file necessary when setting up Tailwind CSS in Vue 3?

Having some trouble setting up Tailwind CSS 2.2.10 on a Vue 3 project without using Vite (so the instructions for "Install Tailwind CSS with Vue 3 and Vite" won't work). In the installation guide, the section on "Adding Tailwind as a PostCSS plugin" ...

Is there a way to prevent the window.status from appearing?

I currently have the following code snippet: <a class="button accessLink" id="loginLink" href="#" data-action="Login" data-dialog="access" data-disabled="false" data-entity="n/a" ...

Take the inputs, calculate the total by multiplying with the price, and then show

I'm in the process of developing a simple PHP form for an online t-shirt order system. Most aspects are running smoothly, but I'm facing issues with the final calculations. My goal is to combine the quantities based on sizes, multiply them by the ...

3.2+ Moodle communication and connections

I am facing a challenge with creating a new div @type@ in /message/templates/message_area_contact.mustache This is the code snippet: ... <div class="name"> {{fullname}} <div style="font-style:italic; font-weight:100;">{ ...

Tips for Customizing Dialogs with CSS Classes in mui5 Using Emotion/Styled

When attempting to customize the styling of a mui Dialog, I encountered an issue where it wouldn't accept className even when placed inside PaperProps. While inline styles worked, my preference was to import styles from a separate stylesheet named Sty ...

Having trouble reading the file using jQuery in Internet Explorer 8 and earlier versions due to its non-XML format (albeit resembling XML)

Currently, I am utilizing AJAX to load a KML file (which essentially functions as an XML file). The parsing works seamlessly in IE9, FF, and other browsers, but encounters issues in IE8. Although the data is retrieved, I face difficulties parsing it in jQu ...

Finding the offsetWidth (or similar measurement) for a list item (LI) element

Can jQuery be used to determine the width of an element? alert($("#theList li:eq(0)").offsetWidth); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ol id="theList"> <li>The quick brown ...

`I'm encountering issues when trying to pass an array through localStorage into a new array`

This is a complex and detailed question that I am struggling to find a solution for. Despite using deprecated mysql due to hosting limitations, the problem lies elsewhere. Part 1 involves dataLoader.php, which queries the database and retrieves posx and p ...

Advancing through time with progress

How can I display a progress indicator for events in fullcalendar based on the current time by changing their color dynamically in HTML? Thank you for your help! ...

Issue with integrating Google Spreadsheet as the data source for a Next.JS website: updates are not reflecting on the website pages

The website for this restaurant was created by me, using Google Spreadsheet to populate the menu pages. I chose this method for its simplicity and familiarity to the client. I'm utilizing the google-spreadsheet package to extract necessary informatio ...

Generating a USA map with DataMaps in d3jsonData

I'm trying to create a basic US map using the DataMaps package and d3 library. Here's what I have attempted so far: <!DOCTYPE html> <html> <head> <title> TEST </title> <script src="https://d3js.org/d3.v5.js"> ...

Steps for updating a value in a JSON file using PHP

Trying to modify a value within a JSON file for a specific object is throwing me off balance. The issue arises from having multiple siblings in the same JSON file sharing identical key-value pairs. The JSON structure I'm dealing with appears as follo ...

Encountering an issue with retrieved items upon refreshing the webpage

My usual approach to fetching data from an external API involves the following steps: Using Fetch API: const [tshirts, setTshirts] = useState([]); const fetchData = () => { fetch('apiEndpoint') .then((response) => ...

The encodeURIComponent function does not provide an encoded URI as an output

Looking to develop a bookmarklet that adds the current page's URL to a specific pre-set URL. javascript:(function(){location.href='example.com/u='+encodeURIComponent(location.href)}()); Even though when I double encode the returned URL usin ...

Setting up a different version of Sails.js on your local machine

After successfully installing Sails.js version 0.9.13 globally on my Mac, I decided to experiment with the 0.10.0-rc4 version locally in a specific folder. Upon running sudo npm install sails@beta, everything seemed fine as the node_modules/package.json s ...

Exploring Angular modules has shed light on a certain behavior that has left me puzzled - specifically, when diving into JavaScript code that includes the

I am currently working with angularjs version 1.4.3 and I find myself puzzled by a certain segment of code in the Jasmine Spec Runner that has been generated. Upon generation, Jasmine (using ChutzPath) creates this particular piece of code: (function ...