Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
pass json outside async function

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!