Within my vuex store, there is a function to create a post. This function generates a json Object containing a unique uuid using uuidv4()
. However, I have noticed that if I execute the function multiple times, the uuid remains the same each time (unless I refresh the page).
// store.js
import uuidv4 from 'uuid/v4';
var uuid = uuidv4();
const state = {
postDetails: {
...
uuid: uuid,
...
}
}
const actions = {
post ({state}) {
var postArray = []
postArray.push(state.postDetails)
// some axios stuff...
}
}
Everything functions correctly except for the fact that the uuid does not change with each call of the function.
I am also using vuex-persistedstate
.