Custom state from api call

Hi! So currently I have a dropdown that whenever the page is loaded it fires an api call that returns as parameters: ids, names. I save them in 2 lists as custom states of the element. One custom state are the names and the other cusotm state are the ids. They both are synced abd in order with each other.

I set the dropdown to display the names, so it’s user friendly. So when the user goes and chooses, there is another workflow thath when that dropdown value is changed another api call is fired.

This second api call needs as parameter an ID.

The issue comes when they choose a name from the first dropdown, how do i link it to its specific id from the other custom state to pass it as parameter???