0👍
If reassigning comments
is okay, this should do the trick:
let unique = [...new Set(state.posts)];
unique.forEach((post) => {
const seenIds = new Set();
post.comments = post.comments.filter((c) => {
if (seenIds.has(c._id)) {
return false; // Already saw it
}
seenIds.add(c._id);
return true;
});
});
- [Vuejs]-How to show a component in Vue.js when an API condition has been met?
- [Vuejs]-Vuetify v-dialog not covering fully the parent page when showed
Source:stackexchange.com