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:
parent
00f0fc9acf
commit
af33acec66
1 changed files with 12 additions and 2 deletions
|
@ -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');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue