I got an app that requires more API calls, so I have my first API call than gets me 20 Objects in which, every object has an independent ID. The second API call is made on the first's call object's IDs.
So my component:
<div>
<table cellSpacing="0">
<thead>
<tr></tr>
</thead>
<tbody>{branded_food_data}</tbody>
</table>
<br></br>
<table cellSpacing="0">
<thead>
<tr></tr>
</thead>
<tbody>{common_food_data}</tbody>
</table>
</div>
common & branded are
<td className="single" style={{ width: "300px" }}>
<span>{name}</span>
<img
src={thumbnail}
alt="thumb"
height="25px"
width="25px"
style={{ float: "right", marginRight: "5px", borderRadius: "1px" }}
></img>
</td>
common and branded are from the first API call and contain the IDs for the second API call.
Now, I want to set react to make the second API call whenever someone clicks on one item() of the rendered common/branded, so I'm thinking the only way I can do it is to get the ID from the first call and set a data-attribute on each so when I click on it, I will set the state in my main component for the ID and fetch that data on that ID. Is there any alternatives to this as I read that is not good practice.
TL:DR
COMPONENT -> (a)API CALL -> {NAME / ID} -> RENDER(multiple TABLEROWS) -> CLICK ON ONE RENDERED TABLEROWS -> GET ID OF CLICKED TABLEROW -> (b)API CALL made on the ID OF CLICKED TABLEROW-> RENDER
How do i set the specific IDS from first call on each specific row?