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

How should I combine useAuthSession with a simple axios wrapper? #5902

Open
MohammadMiras opened this issue Feb 28, 2024 · 0 comments
Open

Comments

@MohammadMiras
Copy link

I want to get the JWT that is inside the session and add it to the headers of the requests that I send to the API, but I can't use useAuthSession in the Axios configuration file

axiosApi.interceptors.request.use(config => {
    config.headers["Accept"] = "application/json"
    config.headers["X-Client"] = "Qwik"
    return config
})

I get this error when I use UseAuthSession

Error: Code(20): Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method.

I understand the reason for this error, but is there any way I can get the session?

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