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

171
Vistas
What's the best practice around exporting an async value in JavaScript?

In the code snippet below, I'm trying to export a value that relies on async operations. Is this the best way to do that? It just feels a bit weird.

I'd love any suggestions! Thanks!

import ohm from "ohm-js";

export default await (async () => {
  let response = await fetch("./grammar.ohm");
  let source = await response.text();
  return ohm.grammar(source);
})();

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You don't need the async IIFE:

import ohm from "ohm-js";

let response = await fetch("./grammar.ohm");
let source = await response.text();
export default await ohm.grammar(source);
about 4 years ago · Juan Pablo Isaza Denunciar
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