How can I using useCookie in Nuxt 3 - Laravel API directory?

22 Views Asked by At

I'm trying to get cookie with name XSRF_TOKEN when execute login function with laravel sanctum (breeze api) through "http://localhost:8000/sanctum/csrf-cookie" and nuxt 3, but I got undefinded value? What's step wrong from me?

...

TOKEN SET UP ON COOKIE

const CSRF_COOKIE = ref("XSRF-TOKEN")
const CSRF_HEADER = ref("X-XSRF-TOKEN")

async function handleLogin() {
  await useFetch('http://127.0.0.1:8000/sanctum/csrf-cookie', {
    credentials: 'include'
  });

  const token = useCookie(CSRF_COOKIE.value);

  console.log(token.value);
}

Token return undefinded value.

0

There are 0 best solutions below