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

172
Views
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 answers
Answer question

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 Report
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!