In case any one wants the solution (it took me all day to figure it out), here is my discussion post HTML widget code, which depends upon an exposed prompts.json file generated from my YAML data:
<div id="prompt">Refresh the page if the discussion post prompt has not loaded here.</div>
<script>
getText("prompts.json");
const cid = {cid};
async function getText(file) {
let response = await fetch(file);
let data = await response.json();
let messageObj = data.find(item => item.cid === cid);
let message = messageObj ? messageObj.message : 'Discussion post prompt not found. It may not be ready yet, but will be a few days before the relevant class.';
document.getElementById("prompt").innerHTML = message;
}
</script>
Thanks, @baris, for the pointer.