Encountering vuex error when attempting to send data to Django backend

Currently, I am facing an issue while attempting to transmit data from my Vue.js frontend to the backend using Vuex and Vue-axios. Despite establishing a Vuex store and Vue-axios services, I encounter an error that reads

[vuex] unknown action type: addGeneral
whenever I attempt to transfer the data.

Below is the structure of my Vuex folder:

-store
    -modules
        -app
            -mutations.js
            -state.js
        -general.js
        -index.js
    -actions.js
    -getters.js
    -index.js
    -mutations.js
    -state.js

Take a look at the content of module/general.js:

import { ApiService } from '@/services/api.service'
import { FETCH_GENERAL,
  ADD_GENERAL
} from '../actions'
import { FETCH_START,
  FETCH_END,
  SET_GENERAL,
  SET_ERROR,
} from '../mutations'

// Define state, getters, actions, and mutations

Here's what's included in module/index.js:

import necessary modules

Refer to store/actions.js:

export const FETCH_GENERAL = "fetchGeneral";
export const ADD_GENERAL = "addGeneral";

Below you'll find store/index.js:

Setup the Vuex store

Examine store/mutations.js:

Define mutation types

Regarding the vue-axios folder structure:

-services
    -api.services.js
    -config.js

Review the content of services/api.services.js:

Configure API services

Here is the content of config.js:

Define API URL

Lastly, here's a snippet from my Vue.js component:

Implement a method to add general data

In conclusion, what could be causing the error and what steps should I take to resolve it effectively?

Answer №1

If you have namespaced: true enabled, make sure to include the module name when using dispatch

    submitData(info) {
        this.$store.dispatch('data/' + SAVE_DATA, info)
    }

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

Enhance the appearance of CodeMirror substrings by applying bold formatting without altering

I am currently utilizing codemirror with primefaces extensions in XML Mode. I need to modify the font style of a specific substring to make it bold. For instance, <User> <Name>Micheal</Name> <Age>25</Age> <Addr ...

react-native-track-player failing to play song requested from Express server

I set up an expressjs server with a 'songs' route that serves .mp3 files. Here is the code for the Songs Route: import express from "express" const path = require("path") const router = express.Router() ... router.get(" ...

Exploring Angular's Implementation of D3 Force Simulation

Looking to incorporate a d3 force simulation in my Angular app. I have a run method that initializes and sets simulation options, as well as a ticked method that updates the simulation on each tick. However, I've encountered a few problems with this s ...

Transitioning to TypeScript: Why won't my function get identified?

I am in the process of transitioning a functional JavaScript project to TypeScript. The project incorporates nightwatch.js Below is my primary test class: declare function require(path: string): any; import * as dotenv from "dotenv"; import signinPage = ...

Vue form mysteriously invisible

After attempting to create a Products form using VueJS, I encountered an issue where my localhost simply displayed a blank page upon refreshing. Here is the screenshot of the page Despite restarting XAMPP, the problem persisted with only a blank page bein ...

Issue: "Access denied to load local file resource: file://sharedpath"

When trying to run the code on a server with nodejs in Chrome, it seems to not be working as expected. <span><a href="file://sharedpath" target="_blank">Open folder.</a></span> The error message I am encountering in the developer ...

Effective methods to avoid showcasing AdSense advertisements

For the purpose of creating a responsive design, I am attempting to hide an adsense ad unit on smaller screen sizes. Although I am familiar with the method of using css media queries as outlined on Google AdSense support page, I have encountered an error w ...

Inject object into data attribute

I currently have data stored in a specific attribute like this: <div data-id=""> Within my markdown file, I also have a frontmatter variable like this: id: rick My goal is to pass that variable into the data-id attribute, which only accep ...

Preserve multiple selected values post form submission using PHP, HTML, and JavaScript

How can I retain the selected values in a form after it is submitted? My current code functions correctly when only one value is selected, but does not maintain all selected values when multiple are chosen simultaneously. Any assistance would be apprecia ...

Enhancing a node.js application with express()

I am currently utilizing Express MVC with node.js. The primary object I am working with is express(), which is assigned to an alias called app: var express = require('express'); app = express(); Is there a way for me to expand the functionali ...

The functionality of the Sticky state is not effective when it is implemented on a state that contains parameters

It appears that the sticky state feature does not function properly when there are parameters involved. For example: $stateProvider .state('store', { url: '/store', abstract: true, onEnter: ...

Improprove the performance of an array of objects using JavaScript

Hello there, I am currently in the process of creating an array. this.data = [{ label: 'Total', count: details.request.length, }, { label: 'In-Progress', count: details.request.filter((obj) => obj.statusId === 0 || ob ...

Creating an input range element and its event handler dynamically within the ajaxStop function allows for real-time updates based on the

As a beginner in JavaScript development and Ajax, I am currently working on creating a webpage that utilizes Ajax to fetch data from a server. The data is then used to draw geoJSON features on a map using Leaflet. These feature sets need to be toggleable f ...

The image located at 'http://localhost:8080/favicon.ico' was unable to load due to a violation of its content

I am currently developing a JavaScript app called food2fork. I encountered an issue when the AJAX call API promise is fulfilled and the results (recipes) are rendered. However, when I click on one of the recipes, it moves to the next page and displays: ...

Animate sliding bar to move from the left using jQuery

I am currently experiencing an issue with a sliding animation on mouseover in the navigation. The animation works fine, but the problem arises when I hover over any menu item - the sliding bar starts from the very left instead of starting where the navigat ...

Display the dropdown selected value within a Laravel Blade template

I am facing an issue with passing the selected value from a drop-down to another Blade file in Laravel. I have tried using Ajax and jQuery, but it doesn't seem to work for me. I want to display the selected value on the content.blade.php page without ...

Determine the y-coordinate of terrain in Three.js

I have acquired a Collada model of terrain and now wish to incorporate other models onto this terrain. To achieve this, I believe I need to retrieve the height coordinate (y) of the terrain based on specific x and z coordinates. Can someone please guide ...

Managing various names of child objects in a recursive manner

I'm currently facing a challenge while working on a nested JSON feed using D3.js Although my code is functioning properly when the child object is named children, I am interested in displaying nodes for other objects as well, not just the ones labele ...

Is using float:right making the jquery slide toggle dropdown div (triggered by hover) appear glitchy?

Utilizing jQuery's slidetoggle and hover functions, I have successfully implemented a dropdown feature in my div. Within this div, there is various information displayed including the date, a note counter, and three buttons. The first two are Tumblr ...

What is the best way to test for errors thrown by async functions using chai or chai-as-promised?

Below is the function in question: async foo() : Promise<Object> { if(...) throw new Error } I'm wondering how I should go about testing whether the error is thrown. This is my current approach: it("checking for thrown error", asy ...