Hi there I was wondering if it's possible to do imports inside a for loop. When trying to execute this code:
const fs = require('fs');
function importFiles(x) {
fs.readdir(x, (err, files) => {
files.forEach(file => {
var doc = file
var char = /.+(?=\.\w+)/.exec(file);
import {doc} from str(x + char);
});
})
}
importFiles('../public/img/');
I get SyntaxError: Unexpected token import
. Obviously this might be wishful thinking (since I cannot find any documentation on this) but I was wondering if I could somehow decide on how much to import within a function.