Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading '$auth') #27

Open
Slluxx opened this issue Aug 28, 2024 · 1 comment
Open

Cannot read properties of undefined (reading '$auth') #27

Slluxx opened this issue Aug 28, 2024 · 1 comment

Comments

@Slluxx
Copy link

Slluxx commented Aug 28, 2024

I installed it using npm i vue-authenticate-2 (the readme just says vue-authenticate btw) and axios. Following the readme to include it (which it does without throwing any errors), i can not use this.$auth in any of my vue files.

    "axios": "^1.7.5",
    "vue": "^3",
    "vue-authenticate-2": "^2.2.0",
    "vue-router": "^4.4.3",

Node v20.15.0

@Slluxx
Copy link
Author

Slluxx commented Aug 28, 2024

chatgpt helped me out with a few ideas and apparently it works like this

import { getCurrentInstance } from 'vue';
const { appContext } = getCurrentInstance();
const $auth = appContext.config.globalProperties.$auth;

but i believe this is not the intended way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant