Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
Loop Store Dispatch

I want to loop over a array with object through a function to create per object a call through store dispatch.

const action = [{ action: 'FILE_CREATE'}, {action: 'MEDIA_CREATE}]

Call the function:

saveComponent(action)

Function

const saveComponent = async (actions, actionOption, redirect, reload) => {
  await Promise.all(actions.map(obj =>
    store.dispatch(Actions[obj.action]).then(() => {
      console.log(obj.action + ' test ')
      }).catch((error) => {
        Swal.fire({
                text: "Sorry, looks like there are some errors detected, please try again.",
                icon: "error",
                buttonsStyling: false,
                confirmButtonText: "Ok, got it!",
                customClass: {
                confirmButton: "btn btn-primary",
                },
            });
            return false;
    }).finally(() => {
        loading.value = false;
    })
  ));
}

The error on console I get is the following: Uncaught (in promise) Error: [vuex] expects string as the type, but found undefined. which results on the following line: store.dispatch(Actions[obj.action])

If I delete the store.dispatch function, and replace it with: console.log(obj.action) it shows the correct data. Also if I just create one store.dispatch function without the Promise.all. It does work. The actions are registered and working fully.

What am I doing wrong?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!