Feathers-vuex: mapActions patch error Invalid attempt to destructure non-iterable instance

Created on 31 Oct 2019  路  6Comments  路  Source: feathersjs-ecosystem/feathers-vuex

If patch method is used via mapActions then get the below error.
But, patch works if called directly via client.service('buy').patch(this.thisOrder.id, this.thisOrder, {})

Error in client

nonIterableRest.js?061d:2 Uncaught TypeError: Invalid attempt to destructure non-iterable instance
    at _nonIterableRest (nonIterableRest.js?061d:2)
    at _slicedToArray (slicedToArray.js?f3e3:8)
    at Store.patch (service-module.actions.js?6ac1:155)
    at Array.wrappedActionHandler (vuex.esm.js?2f62:732)
    at Store.dispatch (vuex.esm.js?2f62:437)
    at Store.boundDispatch [as dispatch] (vuex.esm.js?2f62:331)
    at Store.local.dispatch (vuex.esm.js?2f62:662)
    at VueComponent.mappedAction (vuex.esm.js?2f62:935)

mapActions

    ...mapActions("buy", {
      verifyPayment: "patch"
    }),

Patch call

return this.verifyPayment(this.thisOrder.id, this.thisOrder, {})

Most helpful comment

@apmcodes @aessig
That's correct, you need to pass id, data and params in an array as vuex actions only takes one param.

https://github.com/feathersjs-ecosystem/feathers-vuex/blob/250901daf99ce0512a2046dd94a6ccaea2a5164e/src/service-module/service-module.actions.ts#L148

So you must call it like that:

return this.verifyPayment([this.thisOrder.id, this.thisOrder])

All 6 comments

Which version do you have in your node_modules folder. Please check the package.json in node_modules and update here.

Sure.

node_modules

  "_from": "feathers-vuex@^2.0.4",
  "_id": "[email protected]",

package.json

"feathers-vuex": "^2.0.4",

Could this be because the object/ record is not in the vuex store? FYI. It's a custom feathers service.

@apmcodes I have the same problem here, have you been able to find a solution?

@aessig try passing id and data as an array to mapped action such as patch. Like verifyPayment([id, data, params])

@apmcodes @aessig
That's correct, you need to pass id, data and params in an array as vuex actions only takes one param.

https://github.com/feathersjs-ecosystem/feathers-vuex/blob/250901daf99ce0512a2046dd94a6ccaea2a5164e/src/service-module/service-module.actions.ts#L148

So you must call it like that:

return this.verifyPayment([this.thisOrder.id, this.thisOrder])
Was this page helpful?
0 / 5 - 0 ratings

Related issues

RubyRubenstahl picture RubyRubenstahl  路  5Comments

beeplin picture beeplin  路  8Comments

kshitizshankar picture kshitizshankar  路  7Comments

tguelcan picture tguelcan  路  6Comments

juancampuzano picture juancampuzano  路  4Comments