Skip to content

Instantly share code, notes, and snippets.

@xtiannyeto
Created September 27, 2021 11:08
Show Gist options
  • Save xtiannyeto/b1f644bb4d232a0431fc92ffc8ac6d13 to your computer and use it in GitHub Desktop.
Save xtiannyeto/b1f644bb4d232a0431fc92ffc8ac6d13 to your computer and use it in GitHub Desktop.
<template>
<button @click="signIn">login</button>
<button @click="signOut">log out</button>
<div>{{ user }}</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref } from '@vue/runtime-core';
import { initFacebook, login, logout } from './FacebookAuth';
export default defineComponent({
name: 'SignIn',
setup(props, { emit }) {
const user = ref({});
async function signIn() {
const result = await login();
if (result) user.value = result;
}
async function signOut() {
logout();
}
onMounted(async () => {
initFacebook(process.env.FACEBOOK_APP_ID);
});
return { user, signIn, signOut };
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment