Created
September 27, 2021 11:08
-
-
Save xtiannyeto/b1f644bb4d232a0431fc92ffc8ac6d13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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