1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-02 19:55:18 +02:00

feat: Add session cookie to API requests in profile page server load

This commit is contained in:
Sean Morley 2025-02-16 12:53:58 -05:00
parent 00f0fc9acf
commit af33acec66

View file

@ -16,14 +16,24 @@ export const load: PageServerLoad = async (event: RequestEvent) => {
// let sessionId = event.cookies.get('sessionid');
let stats = null;
let res = await event.fetch(`${endpoint}/api/stats/counts/${username}`, {});
let res = await event.fetch(`${endpoint}/api/stats/counts/${username}`, {
headers: {
'Content-Type': 'application/json',
Cookie: `sessionid=${event.cookies.get('sessionid')}`
}
});
if (!res.ok) {
console.error('Failed to fetch user stats');
} else {
stats = await res.json();
}
let userData = await event.fetch(`${endpoint}/auth/user/${username}/`);
let userData = await event.fetch(`${endpoint}/auth/user/${username}/`, {
headers: {
'Content-Type': 'application/json',
Cookie: `sessionid=${event.cookies.get('sessionid')}`
}
});
if (!userData.ok) {
return error(404, 'Not found');
}