Using Vue.js along with the vuex store, I make an API call to validate an item, which returns arrays of errors and warnings.
Below is my vuex action :
export function validateitemReview ({ commit, dispatch, state }, { reviewId, type, itemreviewData }) {
console.log('*** validateItemReview() called')
return api.post(`/clients/districts/reviews/${reviewId}/${type}/validate`, itemreviewData).then(response => {
console.log('response.data :')
console.log(response.data)
commit('setItemReviewsErrors', 'teststring')
})
}
The setItemReviewsErrors
mutation in the vuex store doesn't do much with the response yet :
export const setItemReviewsErrors = (state, data) => {
console.log('*** setItemReviewsErrors() called, data:')
console.log(data)
}
However, the issue arises when the following error occurs :
Uncaught (in promise) TypeError: Converting circular structure to JSON
at JSON.stringify (<anonymous>)
at eval (vuex-persistedstate.es.js?0e44:1)
at eval (vuex-persistedstate.es.js?0e44:1)
at eval (vuex.esm.js?2f62:392)
at Array.forEach (<anonymous>)
at Store.commit (vuex.esm.js?2f62:392)
at Store.boundCommit [as commit] (vuex.esm.js?2f62:335)
at local.commit (vuex.esm.js?2f62:651)
at eval (itemreview_actions.js?0d87:62)
Further investigation reveals that this problem may be related to the vuex-persistedstate
plugin being used. Others have faced similar issues as well :
https://github.com/robinvdvleuten/vuex-persistedstate/issues/152
https://github.com/robinvdvleuten/vuex-persistedstate/issues/41
Unfortunately, the developer seems to have closed the tickets without a solution. If anyone has any insights on resolving this issue without removing the persistence plugin, please share.