Next.js - How to Filter an Array of Objects for a Specific ID
Last updated: Sep 26, 2022
Hello ! I need help of this : I have a VanguardsList document containing a Vanguards array of vanguard object . I set an id for every vanguard (which I use as a slug for my dynamic routing in NextJs). inside NextJs getStaticProps(), I only want to fetch the vanguard object matching the id (the current slug of the page..).
Currently, I am able to filter de data but I still get an array containing multiples objects (all empty except the one with the right id).
I want to query only the object witht he right id (without the empty ones)
first img is document structure and second is query inside Vision
Sep 26, 2022, 9:29 PM
! You man move the filter up to your array like so to only return the items with a matching id: