Vuex getter help

hi, iam using vuex in my project and iam calling getter in one of my component but it is a sort of function that return a function but what i want is its return value. please help.
i want mappedProducts

please see the code.


someMethod(state) {
    return (value) => {
      const items = state.products[value]

      let categoryProducts = [...items]
      const mappedProducts = categoryProducts.splice(0, 4)

      return mappedProducts
    }

You are likely going to have to give some more context here. Where is the function defined and where and how is it used? Do you have a repo with the code?

But just in general, for functions that return functions, you can use double parentheses to invoke the returned function immediately (which would return the return value of the inner function).

someMethod(someArg)()


FYI, I don’t really use Vue or Vuex so I might not be able to answer your question.

thanks. for spending time on my question and for your answer

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.