Closed elceka closed 7 years ago
I don't see any error in your function call. It should work.
@elceka: I fixed the bug in https://github.com/christianmalek/vuex-rest-api/commit/7b582a3cfcfb46d690b6a8cf83b9a12b87f4b309 and published a new version in npm.
As you can see in https://github.com/vuejs/vuex/issues/373 Vuex doesn't allow three parameters as function signature for actions (the first param is for the context, it's not visible for you if you use the vuex-rest-api). Therefore you need to pass the parameters
and data
(payload) in the same object as follows:
createChildren({
params: {parentId: 'c539fba9-5ee1-3670-b320-11fb967ce11c'},
data: {name: 'Pedro'}
})
Thank you, fixed!
Hi, please, how can i put payload to the POST action?
I have this action in Resource object:
.addAction({ action: 'createChildren' method: 'post', property: 'children', pathFn: ({ parentId }) => '/parents/${parentId}/childrens' })
From component i call this:
createChildren({parentId:'c539fba9-5ee1-3670-b320-11fb967ce11c'}, {name:'Pedro'})
HTTP request has been ok (with correct URI), but payload has been empty.