The call stack limit has been exceeded in VueJS/VueX

I'm currently developing a Vue project with Vuex for state management. However, I encountered a Maximum call stack size exceeded error in my console when attempting to bind actions and getters in my component using mapActions and mapGetters.

I'm unsure of what mistake I may be making in the process.

https://i.sstatic.net/FYMqT.png

import Vue from 'vue'
import Vuex from 'vuex'
import service from "../services/statisticsService"
import moment from 'moment'

Vue.use(Vuex)

const state = {
    customersAndServicesOverTime:[],
    counters:{}
}
const actions = {
    actGetAllData(context){
        context.dispatch('actGetCustomersAndServicesOverTime')
        context.dispatch('actGetCounters')
    },

    actGetCustomersAndServicesOverTime(context){
        service.getCustomerAndServicesOverTime(context.getters.getJWT)
            .then(response =>{
                context.commit('mutCustomersAndServicesOverTime', response.body)
            })
    },
    actGetCounters(context){
        service.getCounts(context.getters.getJWT)
            .then(response =>{
                context.commit('mutCounts', response.body)
            })
    }
}
const mutations = {
    mutCustomersAndServicesOverTime(state,payload){
        state.customersAndServicesOverTime ={
            labels:payload.map(x => moment(x.created).format("DD-MM-YYYY")),
            datasets:[{
                data:payload.map(x => x.customersCount), 
                backgroundColor:"rgba(52, 73, 94,0.5)", 
                label:"customers",lineTension:0
            },{
                data:payload.map(x => x.servicesCount),
                backgroundColor:"rgba(230, 126, 34,0.5)", 
                label:"services",lineTension:0
            }]}
    },
    mutCounts(state,payload){
        state.counters = payload
    },
}
const getters = {
    getCustomersAndServicesOverTime:state=>state.customersAndServicesOverTime,
    getCounts:state=>state.counters,
}

export default {
    state,
    getters,
    actions,
    mutations
}

Within my service file, I have defined two functions that interact with my API.

import Vue from 'vue'
import VueResource from 'vue-resource'
import CONFIG from "../config"

export default {
    getCounts(jwt) {
        return Vue.http.get(CONFIG.API + "statistics/counts", {
            headers: {
                'Content-Type': 'application/json'
                ,'Authorization': 'Bearer ' + jwt
            }
        })
    },
    getCustomerAndServicesOverTime(jwt) {
        return Vue.http.get(CONFIG.API + "statistics/customersandservicesovertime", {
            headers: {
                'Content-Type': 'application/json'
                ,'Authorization': 'Bearer ' + jwt
            }
        })
    }
}

Answer №1

The issue I encountered was not related to vuex. It turns out that using vue-chartjs, I neglected to make a hard copy of my object instance and instead used it as a reference. This led to the error message stating "Maximum call stack size exceeded."

For more information, you can visit: https://github.com/apertureless/vue-chartjs/issues/197

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

Combine two arrays and collapse one of the nested elements

I need help merging two arrays based on ID and flattening one of the objects. I haven't been able to find a solution for my specific case. This is what I'm attempting and what I've managed to achieve so far: const a = { someProperty: &a ...

Arrange text in a line below neatly in a list

My goal is to line up items on the same row, as shown in the screenshot. I need the opening hours to align consistently in the list. The data is retrieved from a database and displayed using Vue. This is how I currently display the opening hours and days. ...

Ways to retrieve output from a JavaScript function

How can I successfully return the result from response.on within the signIn function? const signIn = async (password) => { var request = new DeviceAuthQuery(); request.setPassword(password); var response = client.authenticate(request, {}, (err, ...

Sliding Image Menu using jQuery

I am struggling with creating a menu using jquery mouseenter / mouseout effects. My goal is to have a small icon displayed that expands to the left and reveals the menu link when a user hovers over it. The issue I am facing is that the effect only works w ...

Establishing relationships with Sequelize between tables in different schemas

Currently, I am working on a project that involves using Sequelize and PostgreSQL as the database. In this project, I have implemented dynamic schema creation whenever a new user registers on the website. Specifically, I have a table called user_credentia ...

Sending the format of the display value to an Angular component

Looking for a way to pass display value formatting to an Angular component. Here are a couple of examples: format="'(utc, offset) location (tz)'" === '(UTC -04:00) New York (EDT)' or format="'(tz, offset) location'" === &a ...

Can orbit controls be tweened in three.js?

When utilizing the TWEEN function within three.js, I have noticed that it is mainly used for tweening objects. Although I can successfully tween the camera's position, I am looking to also tween the orbit control to mimic following a target while the ...

Tips for altering the browser tab color on a PC or Mac with HTML or JavaScript

While I am aware of the method to change theme colors on mobile devices using <meta name="theme-color" content=" #0000ffbb" />, I prefer browsing on my laptop. Are there ways to customize browser tab appearance using HTML or JS fo ...

Is there a way to retrieve the value of an HTML form in order to utilize it within a JavaScript function

I am currently working on developing a temperature converter that utilizes a single number input form. When the form is submitted, it should convert the temperature to either Fahrenheit or Celsius. Unfortunately, as a beginner in JavaScript, I have limited ...

Using a combination of two distinct storage solutions simultaneously is an effective way to optimize data management and access

I'm currently working with the latest version of Vue 2 and the newest Vue2-Storage plugin. My objective is to utilize both local storage and session storage simultaneously. Specifically, I want to save application configuration information in local s ...

Replace or update the current array of objects that align with the incoming array

I've been struggling to figure out how to find and replace an array that matches the existing one. The issue lies with using the some method. Here is the current array: let existingData = [{ id: 1, product: 'Soap', price: ' ...

Using React for form validation

I'm facing a challenge while trying to develop a user registration form, especially when it comes to displaying form validation errors. Issues: 1) The input fails to post (via axios) to the database upon submission for inputs without errors. 2) The e ...

When an accordion is clicked, the content is dynamically loaded within the accordion on the page using PHP, jQuery, and AJAX

To optimize the loading speed of my information-filled page connected to two databases using php, javascript, jquery, I'm looking for a way to make the upload process faster. Currently, some data is displayed immediately while other details are hidden ...

Trouble with downloading files using the anchor (a) tag in React

Every time I try to click on the a tag to download the file named approved_leads.zip, I keep receiving an error message saying "failed - no file". It seems like the path is correct, so I'm not sure what is causing the issue. <a href="../../ass ...

The function(result) is triggered when an http.get request is made

Can anyone help me figure out why my function is jumping after completing the request? It seems to be skipping over .then(function(result){ }. I suspect that the issue might be related to the <a> element with an onclick attribute containing an href ...

The hyperlink element has been added but is not clickable

I'm attempting to incorporate a download feature into my webpage using Greasemonkey. Despite successfully adding the new div element to the page, I am encountering an issue where the download window does not open as expected. var iDiv = document.crea ...

JavaScript and Responsive Design Techniques

I'm struggling to create a responsive page that starts with a mobile-first approach, but I keep running into the same issue. When I have my dropdown menu in the mobile version, it looks good. However, when I try to switch it to the non-mobile version ...

What is the correct syntax for declaring a variable within a switch statement in TypeScript?

How can I properly use a switch statement in TypeScript to assign a new variable a value? For example: let name: string switch(index) { case 0: name = "cat" case 1: name = "dog" .... } I keep getting the err ...

What is the method for triggering two actions within a single linked tag?

I have a link tag structured like this: <a href="<?php echo base_url().'dashboard' ?>" class="check_session">Home</a> Upon clicking the "Home" link, it should navigate to the dashboard. At the dashboard page, I want to check i ...

The loading time for the API response in Laravel is unacceptably slow

When I run my API locally, it works fine. However, when I deploy it to run on a server, it becomes unusually slow. Is this slowness due to my server and how can I check that? Here are some of the responses I received: // Vue import axios from '@axio ...