[Vuejs]-TypeScript + Vue: Loading static json configuration when opening index.html

3👍

Importing the config file would cause it to be bundled. If you want the config file to be read on demand instead, you could fetch it:

import { onMounted, ref } from 'vue'

export default {
  setup() {
    const config = ref({})

    const fetchData = async () => {
      const resp = await fetch('/finnhub.config.json')
      config.value = await resp.json()
    }

    onMounted(() => {
      fetchData()
    })
  }
}
👤tony19

Leave a comment