vue-master-class
vue-master-class copied to clipboard
[BUG] #4 if user has no post, dont stuck there
will fix the bug #4
Your solution will solve this specific problem, but I think it would be better o do a "catch all" solution. The real problem is the fetchItems action that tries to check if ids is array and then tries to call Object.keys with null or undefined value. we could check if ids has value (is null or undefined) and just assign an empty object or array to ids
fetchItems ({dispatch}, {ids, resource, emoji}) {
if (!ids) ids = {}
ids = Array.isArray(ids) ? ids : Object.keys(ids)
return Promise.all(ids.map(id => dispatch('fetchItem', {id, resource, emoji})))
}