Skip to content

Instantly share code, notes, and snippets.

@Pigamo
Created November 21, 2021 18:29
Show Gist options
  • Save Pigamo/9d2c6633f4044e4fc4b4c8adb7f48e05 to your computer and use it in GitHub Desktop.
Save Pigamo/9d2c6633f4044e4fc4b4c8adb7f48e05 to your computer and use it in GitHub Desktop.
Based on StackOverflow Question, how to import multiple json files dynamically without specifically calling each one
const data = import.meta.glob('../data/*.json')
const imp = ref([{}])
// eslint-disable-next-line no-restricted-syntax
for (const path in data) {
data[path]().then((mod) => {
// const p = new URL(path, import.meta.url)
// eslint-disable-next-line no-console
console.log(path)
// imp.value.push(path)
imp.value.push(mod)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment