laravel 9 Sanctum token #15353
Unanswered
giancarlozucoloto
asked this question in
CLI - SSR mode
Replies: 1 comment 1 reply
-
|
Have a function that sets it up in the header of your axios instance, then call it within your login function or wherever you prefer. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am using laravel 9 sanctum token
the authentication part is all right.
But when I'm inside and I make a request for a route
Protected and returns error 401 unauthorized because when it went through the boot it didn't take time
the token … but if I load the page again the data appears.
Part of the code below:
boot
const api = axios.create({ baseURL: "http://localhost:8000/api/" }); api.defaults.headers["Authorization"] =Bearer ${localStorage.getItem("token"
)}
;posts.vue
`setup() {
const posts = ref([])
Beta Was this translation helpful? Give feedback.
All reactions