Files
MediaManager-maxdorninger/web/src/routes/dashboard/settings/+page.ts
2025-06-22 18:05:21 +02:00

35 lines
686 B
TypeScript

import {env} from '$env/dynamic/public';
import type {PageLoad} from './$types';
const apiUrl = env.PUBLIC_API_URL;
export const load: PageLoad = async ({fetch}) => {
try {
const users = await fetch(apiUrl + '/users/all', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
credentials: 'include'
});
if (!users.ok) {
console.error(`Failed to fetch users: ${users.statusText}`);
return {
users: null
};
}
const usersData = await users.json();
console.log('Fetched users:', usersData);
return {
users: usersData
};
} catch (error) {
console.error('Error fetching users:', error);
return {
users: null
};
}
};