jws-frontend/src/components/upload-file/GetFileUrl.vue
2024-11-19 09:14:43 +07:00

28 lines
483 B
Vue

<script setup lang="ts">
import { api } from 'src/boot/axios';
import { onMounted } from 'vue';
import { ref, watch } from 'vue';
const props = defineProps<{
url: string;
auth?: boolean;
}>();
const file = ref<string>('');
onMounted(getFile);
watch(
() => props.url,
() => getFile,
);
async function getFile() {
file.value = props.auth
? await api.get<string>(props.url).then((res) => res.data)
: props.url;
}
</script>
<template>
<slot :file />
</template>