JSFiddle - React, Tailwind, and code Playground
by alexb
HTML
<select></select>
<select></select>
TypeScript
type Option = string;
async function getOptions(): Promise<Option[]> {
return ['one', 'two'];
}
async function populateOptions(selectEl) {
const options = await getOptions();
for (let x of options) {
console.log(x);
const el = document.createElement('option');
el.innerText = x;
selectEl.appendChild(el);
}
}
populateOptions(document.querySelector('select'));