1π
β
I donβt think itβs possible with a single line. You can achieve it in this way:
const getters = {
errors: (state) => {
let newErrors = {};
Object.keys(state.errors).map( key => newErrors[key] = state.errors[key].join(' ') )
return newErrors;
}
};
π€Fab
2π
A reducer should work for the one liner.
const getters = {
errors: state => Object.keys(state.errors).reduce((acc, key) => {
acc[key] = state.errors[key].join(' ')
return acc
}, {})
};
π€Borjante
Source:stackexchange.com