Skip to content

Commit fc553a7

Browse files
committed
Fix base-model find and get getters
An array was incorrectly getting passed to the BaseModel’s getGetter. This was resulting in no data being returned any time you wanted to pass `id` and `params` to the getter. This fixes that situation, making sure an array is not passed to the getters.
1 parent 225ee31 commit fc553a7

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/service-module/make-base-model.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,22 +193,19 @@ export default function makeBaseModel(options: FeathersVuexOptions) {
193193
}
194194

195195
/**
196-
* An alias for store.getters
196+
* An alias for store.getters. Can only call function-based getters, since
197+
* it's meant for only `find` and `get`.
197198
* @param method the vuex getter name without the namespace
198199
* @param payload if provided, the getter will be called as a function
199200
*/
200-
public static _getters(name: string, payload?: any) {
201+
public static _getters(name: string, idOrParams?: any, params?: any) {
201202
const { namespace, store } = this
202203

203204
if (checkNamespace(namespace, this, options.debug)) {
204205
if (!store.getters.hasOwnProperty(`${namespace}/${name}`)) {
205206
throw new Error(`Could not find getter named ${namespace}/${name}`)
206207
}
207-
if (payload !== undefined) {
208-
return store.getters[`${namespace}/${name}`](payload)
209-
} else {
210-
return store.getters[`${namespace}/${name}`]
211-
}
208+
return store.getters[`${namespace}/${name}`](idOrParams, params)
212209
}
213210
}
214211
/**

0 commit comments

Comments
 (0)