I have 2 seperate files with various JS functions on them. I want to import either one based on a condition. I am unsure how to do this.
I have:
import { mainURL } from '../../support/helperFunctions.js';
let dataPath = '../../../data/data.js';
if (mainURL.includes('dev')) {
dataPath = '../../../data/dataDev.js';
}
import { coreData, lastUpdated } from dataPath;
But I get the error Unexpected token
for the import line.
I’ve also tried
if (mainURL.includes('dev')) {
import { coreData, lastUpdated } from '../../../data/dataDev.js';
}
else {
import { coreData, lastUpdated } from '../../../data/data.js';
}
And a few other variations of this.
Would anyone know how to achieve this in node?