I know it was asked before plenty of times but for the life of me I can't figure out the proper way to make it work. I am working on NodeJS project. I need to display a certain value in the based on query results, but also have that populated with all available options. My function to initially populate works properly.
async function fillDatalist(){
await $('#html_placeholder').load('/path/to/some.html', function() {
getValues_for_Datalist()
});
}
After I get specific values from database, i need to display it.
async function display_value_from_DB (value_string) {
await fillDatalist()
document.getEleemntbyID(datalist_id).value = value_string
}
I get en error:
Uncaught (in promise) TypeError: Cannot set property 'value' of null
Which i believe is that due to the fact that function fillDatalist did not complete.
Thanks in advance for any help.