After setting an ES6 class to the state in my vuex store in nuxt, I encountered the following warning:
WARN Cannot stringify arbitrary non-POJOs EndPoint
However, when I use an object as the state, it works without any warnings.
So the question arises, how can I effectively utilize ES6 classes in my state?
Below is my model:
export default class EndPoint {
constructor(newEndPoints) {
this.login = newEndPoints.login;
this.status = newEndPoints.status;
}
}
and this is how I mutate the state:
commit(CoreMutations.SET_ENDPOINTS, new EndPoint(response.data));
When using an object:
const EndPoint = {
endPoints(newEndPoints) {
return {
login: newEndPoints.login,
status: newEndPoints.status
};
}
};
and mutating as follows:
commit(CoreMutations.SET_ENDPOINTS, EndPoint.endPoints(response.data));