Dynamic List Configuration

I am building my first custom module and in my configuration file I need to have a drop down list of files in a directory. I've got the basic dynamic build of the list working (thanks to the serial port module).

Everything works if I comment out these lines:

			fs.readdirSync(testFolder).forEach(file => {
					console.log(file);
			})

But uncommented my drop down doesn't show up - seems to fail on this line and therefore stops executing code.

What am i missing?

oneditprepare: function() {
		blist = buildlist(".");

		var vswitch = "custom";
		for (var i in blist) {
			if (this.switches == blist[i].value) {
				vswitch = this.switches;
			}
		}
		$("#node-config-input-switches").typedInput({
			default: this.switches,
			types:blist
		});   
		
	}, //end of on edit prepare

	oneditsave: function() {
	    var mytype = $("#node-config-input-switches").typedInput('type');
		$("#node-config-input-switches").typedInput('value',mytype);
		this.switches = $("#node-config-input-switches").typedInput('value');
	}  //end of on edit save

});

Fs is a server side (nodejs) call. The config window is in your browser. Slight disconnect there.

You need to make an (Ajax) request from browser to the backend? Read the files there, then return the list to the browser.

Of course - that makes total sense.

Any tips or examples of how to do this? I have been googling around but have not found anything helpful yet.

Thanks for the help.

Hi @bertmartin

this StackOverflow answer covers the basic approach for creating a custom admin endpoint in the runtime that your edit dialog can call to get data from the runtime side - https://stackoverflow.com/questions/41567175/send-data-on-configuration/41567832#41567832