@millergeek/vue-library-printable-zine
Version:
A vue library for creating printable zines
25 lines (24 loc) • 536 B
JavaScript
import { ref, toValue, watchEffect } from "vue";
import { ofetch } from "ofetch";
export const useGitHubUser = (name) => {
const user = ref(null);
const isLoading = ref(false);
watchEffect(async () => {
if (!toValue(name)) {
return;
}
await fetchUser();
});
async function fetchUser() {
isLoading.value = true;
user.value = await ofetch(
`https://api.github.com/users/${toValue(name)}`
).finally(() => {
isLoading.value = false;
});
}
return {
user,
isLoading
};
};