Open Nizzy94 opened 3 years ago
What is written in the docs (linked) didn't work until I made this correction:
import gAuth from 'vue3-google-auth'
const $gAuth = gAuth.useGAuth()
Edit: Nevermind. Console is still saying it is not a function. Updating above to match the docs.
This is the error that appears in console when trying to invoke gAuth.useGAuth
:
vue3_google_oauth2__WEBPACK_IMPORTED_MODULE_5__.default.useGAuth is not a function
It should be noted that the linked docs are for an older version and the current version's NPM documentation has omitted the instructions for calling the GAuth methods during setup()
. It's pretty important to have access to everything in setup()
as often it is necessary to make sure login issues are handled before the rest of the app tries to make it's backend server requests on page load. This is a good example of why mixing the composition and options APIs is considered an anti-pattern.
import { getCurrentInstance, onMounted } from 'vue' const { proxy } = getCurrentInstance() proxy.$gAuth.getAuthCode()
Is there a way to use it in the composition API? from the coding example, it was used in the Options API and I had to combine it with the composition API.