I have a problem that my cookie is not being set immediately after the request, i need to reload the page for the cookie to be available but i dont want to interfere with the user's experience
const resp = await $fetch("/api/auth/login", {
method: "post",
body: JSON.stringify({
email: email.value,
password: password.value,
}),
});
if (!resp.success) {
status.value = resp.message;
loading.value = false;
return;
}
const authToken = useCookie("auth-token");
console.log(authToken.value); // Prints "undefined"
const resp = await $fetch("/api/auth/login", {
method: "post",
body: JSON.stringify({
email: email.value,
password: password.value,
}),
});
if (!resp.success) {
status.value = resp.message;
loading.value = false;
return;
}
const authToken = useCookie("auth-token");
console.log(authToken.value); // Prints "undefined"
0 Replies
No replies yetBe the first to reply to this messageJoin