Im trying to pass the jason variable outside an async function, the function is inside a module, and I want to access it with a separate javascript file
<script type="module" src="./build/main.js"></script>
main.js (getSpatialStructure returns a json)
const output_1 = document.getElementById("message_r");
const init = async () => {
const modeloo = await viewer.IFC.loadIfcUrl(ifcURL);
let ifcInfo = await viewer.IFC.getSpatialStructure(modeloo.modelID);
let json_ifc_data = ifcInfo;
output_1.innerHTML = JSON.stringify(ifcInfo, null, 2);
}
init();
separate js
<script type="text/javascript">
json_ifc_data = ?
</script>
Ive been trying to acces it through the innerhtml
$(document).ready(function() {
var jjson_sc = document.getElementById("message_r").innerHTML;
console.log(jjson_sc);
var jjson = document.getElementById("json_esp");
jjson.innerHTML = jjson_sc;
});
or setting the parameter outisde the async function
let json_ifc_data;
const init = async () => {
const modeloo = await viewer.IFC.loadIfcUrl(ifcURL);
let ifcInfo = await viewer.IFC.getSpatialStructure(modeloo.modelID);
let json_ifc_data = ifcInfo;
output_1.innerHTML = JSON.stringify(ifcInfo, null, 2);
}
init();
but both cases the value is undefined
thanks