The Axios API request cannot be customized with parameters

I've been encountering an issue where the values I'm trying to pass to my dispatch function are not being recognized and showing up as undefined. It's puzzling because all the values exist and display properly when logged in the component.

Here's the dispatch call in my component:

  methods: {
    buscar(){
      const formData = {
        user: this.user,
        password: this.password,
        profile: this.profile
      };
      console.log('fomrdata: ',formData)
      this.$store.dispatch('login', formData)
    }
  },

And here's the method in my store:

login(formData) {
  console.log(formData)
 },

Answer №1

In the action, formData needs to be passed as the second parameter.

actions: {
    signIn ({ commit }, formData) {
        console.log(formData);
    }
}

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

Is it possible for bots to mimic onTouch events?

Query: In order to safeguard a mobile website from SPAM/Bots without resorting to user-unfriendly CAPTCHA, we are considering disabling onClick events at the server side while still permitting onTouch events. Can bots emulate the onTouch function, thus e ...

What impact does incorporating a new test case have on code coverage in Jest?

I recently encountered an unexpected situation while working on a Jest test suite. Despite not making any changes to the codebase, I simply added a new test. Originally: mylibrary.js | 95.65 | 89.66 | 100 | 95.65 | 54-56,84 ------------ ...

Use jQuery to categorize <a> links by their text content

Hi, I'm new to jQuery and could use some guidance. Due to the not-so-great output of Go's html/template, I have to rely more on JavaScript (which I'm not very good at). I have a list of unordered links that need to be organized into "paren ...

What causes my local storage to be cleared whenever I refresh the page in React with Redux?

What causes my local storage to reset to empty whenever I refresh the page? I am attempting to save data to local storage that is also passed to my redux state, but I am unable to do so. const retrieveLocalStorage = () => { const oldExpenses = JSON ...

PHP and JavaScript both offer methods for escaping variables that are written in the syntax ${HOST}

How can I safely handle variables from the database like ${HOST}? This issue arises when code is posted within <pre><code> tags. If left as it is, an error occurs: Uncaught ReferenceError: HOST is not defined. In this specific context, usin ...

Add a border to the navigation bar item to indicate the current page being displayed

This section shows the current navigation bar item https://i.sstatic.net/6RAGJ.png This is the desired outcome when clicking on the tab https://i.sstatic.net/8nFeB.png Uncertain about the best approach for achieving this. I have attempted to submit a val ...

When scrolling, the selected text does not maintain its correct position

I'm looking to enable my users to search by selecting text. Once they select text, a new button will appear on the right side of the selected text giving them the option to search or not. However, when the user scrolls to the bottom of the page, the p ...

Is there a way to prevent special characters from being typed without affecting the arrow keys?

To allow input of numbers from 0 to 9 as well as navigation keys such as up, down, left, right, delete, tab, home, and end, including modifier keys like alt and ctrl, this code is compatible with Chrome and Firefox browsers. $('.commonNumber').k ...

What is the best way to create a backup copy of my project using git?

To ensure the safety of my project, I took the necessary steps to back it up. First, I initialized a repository using git init Following that, I committed all files by executing git add . git commit -am "first commit" Now, the next step involves pushin ...

What is the solution for resolving the JavaScript error "TypeError: Cannot read property 'map' of undefined"?

I'm encountering an issue while fetching data from the API and trying to map it to display in a table. The problem is that the fetching process doesn't seem to be working properly, resulting in the state remaining undefined when the page loads. I ...

What is the process for adding parameters to a Fetch GET request?

I have developed a basic Flask jsonify function that returns a JSON Object, although I am not certain if it qualifies as an API. @app.route('/searchData/<int:id>',methods=["GET"]) def searchData(id): return jsonify(searchData(id)) Curr ...

Generate an HTML5 video element dynamically without displaying it on the webpage

Can I create an HTML5 video element dynamically and access it using APIs like document.getElementById or Name without displaying it on the webpage? Is there a way to hide the video element after creating it, similar to div.hide() or something along those ...

Does Visual Studio Code support custom procedural import paths for JavaScript intellisense?

I am looking to implement JS (ESM) intellisense for vscode within the Firefox codebase for a specific distribution of Firefox. Within Firefox, I need to register modules in build scripts like moz.build and import them using paths such as "resource://gre/m ...

Transferring data using a JavaScript enhanced form

I'm currently working on a search page that showcases results in a table format. I am looking to enhance the functionality using Javascript. The table is contained within a form, and each row offers multiple actions, such as adding a comment. While I ...

The color of a PNG image remains consistent in Fabric.js

Below is the code I am using to dynamically change the color of a PNG image on canvas: var selectedObject = canvas.getActiveObject(); if ("text" == selectedObject.type) { selectedObject.setFill("#FF0000"); canvas.renderAll(); } else { selecte ...

Gulp and Vinyl-fs not functioning properly when trying to save in the same folder as the source file due to issues with

After exploring a variety of solutions, I have yet to find success in modifying a file in place using Gulp.js with a globbing pattern. The specific issue I am facing can be found here. This is the code snippet I am currently working with: var fstrm = re ...

Encountering the error message ERR_CONNECTION_TIMED_OUT while using Vue CLI

Currently, I am venturing into the world of Vuex and attempting to incorporate some API requests using this state management pattern. Here is the structure I have set up: Component.Vue export default { created() { this.$store.dispatch('getDat ...

Need help with functions in JavaScript?

I'm struggling with understanding some code related to javascript and angularjs. I came across this line - !function(a,b,c){}(x,y,z) - and I can't make sense of it. It's something new to me and I would appreciate any help in clarifying its p ...

What could be the issue with my injection supplier?

When running the following code, the configuration works fine, but an error is returned: Uncaught Error: [$injector:unpr] Unknown provider: AngularyticsConsoleHandlerProvider <- AngularyticsConsoleHandler <- Angularytics Code snippet: angular.modu ...

Creating code in AngularJS

I have the following template structure: <h1 class="text-center" ng-bind-html="row.text"></h1> When the content of my row.text is a string like this: Hi your name is {{ name }} It will display as shown below: Hi your name is {{ name }} ...