I'm encountering a major challenge with incrementing data.
@Module
class Mod extends VuexModule {
public value = 2; // facing multiple type errors when trying to access this.state.value within a MutationAction.
@MutationAction({ mutate: ["value"] })
async valueIncrement(): Promise<Record<"value", number>> {
const req: AxiosRequest = await axios.get("...randomValue/");
return {
value: this.value += req.data // encountering issues as this.value is undefined
}
}
}
It appears that MutationAction
does not have direct access to the module state?
One workaround I discovered is setting (this.state as this).value
.
Is there any method to directly access the state from a MutationAction
, perhaps with additional configuration?