Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda