js use async as default in import

Viewed 625

Is it possible to have an import automatically be async.

Right now I have to do this:

main.js

import './import.js'

import.js

(async() => {
    const result = await fetch(...); 
    console.log(result);
})();

But I would rather have it without the self invoking function:

import.js

    const result = await fetch(...); 
    console.log(result);
1 Answers
Related