Javascript loop goes too fast and does not change the api call [closed]

I am executing in the google chrome console the following script:

source code
the button click suppose to call an API, but in the API call, I see alwazs the some ID, insted of getting the other two:

Google chrome network result

I did similar code with a foreach, this time I am using a promise with timeout.
Not sure what to do to resolve this, looks like the foreach goes too fast before the changes are applied to the html and the click even is triggered 3 times with the first ID of the array and it suppose to to have 3 different calls.

Any suggestion?