tengo una matriz de objetos que se parece a: (valores ofuscados)
[ { "title": "l", "data": [ { "id": "x", "bodyPart": "x", "equipment": "x", "gifUrl": "h", "name": "x", "target": "x", "broad_target": "x", "ppl": "p", "thumbnail": "h", "heatmap_target": "u" } ] }, {} ] si te das cuenta, hay un {} en blanco.
mi intento de eliminar estos es:
const cleanEmpty = obj => Object.entries(output) .map(([k,v])=>[k,v && typeof v === "object" ? cleanEmpty(v) : v]) .reduce((a,[k,v]) => (v == null ? a : (a[k]=v, a)), {});esto no funciona.
puede usar Array.filter para filtrar los objetos en blanco como este:
const arr = [ { foo: "bar" }, {} ] const newArr = arr.filter(obj => Object.keys(obj).length >= 1) console.log(newArr) //[{foo: "bar"}]