Compruebe esta función de filtro y déjeme saber cómo puedo mejorarla. Estos filtros funcionan individualmente pero no juntos
const filterFunction = (a) => { if (!includeKeyword && !searchVolume && !excludeKeyword && !longtailKeyword){ return true } else if (includeKeyword && !searchVolume){ return a.text.toLowerCase().includes(includeKeyword.toLocaleLowerCase()) } else if (!includeKeyword && searchVolume){ return a.keyword_idea_metrics.avg_monthly_searches > parseInt(searchVolume) } else if (!searchVolume && excludeKeyword){ return !a.text.includes(excludeKeyword) } else if (!excludeKeyword && longtailKeyword){ return a.text.split(" ").length == longtailKeyword } else { return a.text.toLowerCase().includes(includeKeyword.toLocaleLowerCase()) && a.keyword_idea_metrics.avg_monthly_searches > parseInt(searchVolume) && !a.text.includes(excludeKeyword) && a.text.split(" ").length <= longtailKeyword } }Función de procesamiento
postRes.filter(filterFunction).map((data, index) => (realmente agradezco su ayuda de antemano
Actualmente está pasando una función no invocada con un argumento y pasándola correctamente como la devolución de llamada del filter .
Creo que podrías probar postRes.filter((a) => filterFunction(a))...