I have data from an API being mapped in my fronten...
# javascript
a
I have data from an API being mapped in my frontend. These objects have individual keys/ids. On my database, I have data that needs to be mapped and shown next to the relevant objects. How would I do that? Feel free to answer in the thread.
g
In particular part you need feedback on? You can certainly have database objects with matching keys/ids to link them to your API data. Depending on if your api data comes in one at a time you could fetch the database data by key and pair up the data, or if you have a reasonable subset you could us a .in filter to load a set of data by keys.
a
Hey, thanks for responding. The API sends 100 objects per request. Each of these may have a rich-text/markdown string associated with them. I'll take a look at
.in filter
. Are you talking about this? https://supabase.com/docs/reference/javascript/in I think I understand how to do this. So, I can have a
<Object />
component inside my
.map
function and then pass the key as a prop or something and retrieve data using the
.in()
filter. Does that sound good to you?
g
.eq or .match fetches a single record if you are looping. That could be painful though on time. .in fetches all records with ids in the array. But if it gets to be too many records or ids that can also be a problem with length limit of get request url on the web.