Getting tokens failing when navigating to new page
I'm finding that when I navigate between pages, I'm unable to get the access token unless I refresh the page.
This is how I'm trying to retrieve the token;
I've replicated the issue by using the starter project, and adding a
nuxtlink
between /
and /dashboard
. Once the user is logged in, if I navigate to the following /dashboard
the {{ accessToken }}
is empty.
dashboard.vue
index.vue
2 Replies
Thank you for the code examples, let me check this out for you
Hi @bnln,
Thanks for this, your message has made me realise how the documentation is not great here.
Firstly as indicated in the readme, the
useKindeClient()
is a server side only method, so will not exist in subsequent page loads.
If you want to access the token you can store in a ref, but this is not recommended.
You can access the token on server api routes like this
You have raised that our documentation could be better here.
Let me know if this helps or if you have any further questions.thanks @Daniel_Kinde - I'll try this out
actually this worked really well - I ended up moving my post request, where I was using the token, on to the server side, which probably is a much better place for it. Thanks again for the help and guidance. 🙏