wrap auth util functions in try blocks
This commit is contained in:
@@ -2,6 +2,7 @@ import type { User } from "@chessu/types";
|
||||
import { API_URL } from "@/config";
|
||||
|
||||
export const fetchSession = async () => {
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/v1/auth`, {
|
||||
credentials: "include"
|
||||
});
|
||||
@@ -10,9 +11,13 @@ export const fetchSession = async () => {
|
||||
const user: User = await res.json();
|
||||
return user;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
export const setGuestSession = async (name: string) => {
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/v1/auth/guest`, {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
@@ -25,4 +30,7 @@ export const setGuestSession = async (name: string) => {
|
||||
const user: User = await res.json();
|
||||
return user;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user