I need to filter out objects in array if specific key value is null.
const getPlayerData = async () => {
const allPlayers = await fetchData("https://api.sleeper.app/v1/players/nfl");
const players = Object.keys(allPlayers).map(function(key) {
return allPlayers[key]
})
const activePlayers = await Promise.all(players?.filter(async(player: any) => {player.search_rank !== null}
).sort((a, b) => a.search_rank - b.search_rank));
console.log(activePlayers)
return activePlayers;
}
it filters if {player.active = true}
but i need to filter if player.search_rank
is null
aswell