Skip to content

Instantly share code, notes, and snippets.

@ErikCH
Created January 14, 2022 03:51
Show Gist options
  • Save ErikCH/4fc18bec5f20b42b6a07f596611d3781 to your computer and use it in GitHub Desktop.
Save ErikCH/4fc18bec5f20b42b6a07f596611d3781 to your computer and use it in GitHub Desktop.
<script setup lang="ts">
import { ref, useSlots, getCurrentInstance } from "vue";
const props = defineProps<{ url: string }>();
const slots = useSlots();
let res = ref("");
let loading = ref(true);
fetch(props.url)
.then(response => response.json())
.then(response => {
res.value = response;
loading.value = false;
});
getCurrentInstance().render = () =>
slots.default({
res: res.value,
loading: loading.value
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment