Last active
March 27, 2024 06:39
-
-
Save Kcko/bbf2f9a8607eed6dc4c99e009e9a7ce6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES 6, JS without bundlers | |
// 1) fetch('data.json').then().then() ... | |
// 2) import data from './data.json' assert { type: 'json' }; | |
// Vue | |
async function fetchData() { | |
try { | |
const response = await import('@/data.json'); | |
const data = await response.default; // Získání dat z Promise | |
console.log(data); | |
} catch (error) { | |
console.error('Chyba při načítání dat:', error); | |
} | |
} | |
// Or | |
const o = ref([]); | |
const data = import('@/data.json').then(x => { | |
o.value = x.default; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment