{"version":3,"file":"useFetch.js","sources":["../../../../../KNHS.Website.Frontend/script/vue/composables/useFetch.ts"],"sourcesContent":["import { ref } from 'vue';\n\nexport async function useFetch(url: string) {\n const data = ref();\n const error = ref(false);\n const isLoading = ref(true);\n\n try {\n await fetch(url)\n .then((res) => {\n if (!res.ok) {\n throw new Error();\n }\n return res.json();\n })\n .then((json) => {\n data.value = json;\n isLoading.value = false;\n })\n .catch((err) => {\n console.error('error: ' + err);\n error.value = true;\n isLoading.value = false;\n });\n } catch (error) {\n console.error('ERROR', error);\n }\n\n return { data, error, isLoading };\n}\n"],"names":["useFetch","url","data","ref","error","isLoading","res","json","err"],"mappings":"8BAEA,eAAsBA,EAASC,EAAa,CACxC,MAAMC,EAAOC,IACPC,EAAQD,EAAa,EAAK,EAC1BE,EAAYF,EAAa,EAAI,EAE/B,GAAA,CACA,MAAM,MAAMF,CAAG,EACV,KAAMK,GAAQ,CACP,GAAA,CAACA,EAAI,GACL,MAAM,IAAI,MAEd,OAAOA,EAAI,MAAK,CACnB,EACA,KAAMC,GAAS,CACZL,EAAK,MAAQK,EACbF,EAAU,MAAQ,EAAA,CACrB,EACA,MAAOG,GAAQ,CACJ,QAAA,MAAM,UAAYA,CAAG,EAC7BJ,EAAM,MAAQ,GACdC,EAAU,MAAQ,EAAA,CACrB,QACAD,GACG,QAAA,MAAM,QAASA,CAAK,CAChC,CAEO,MAAA,CAAE,KAAAF,EAAM,MAAAE,EAAO,UAAAC,EAC1B"}