Files
playground/src/routes/(app)/thoughts/+page.server.ts

16 lines
302 B
TypeScript

export const load = async ({ fetch, url }) => {
const limit = 8;
const page = Number(url.searchParams.get('page')) || 1;
const response = await fetch(`/api/thoughts?limit=${limit}&page=${page}`);
const { posts, total } = await response.json();
return {
posts,
total,
page,
limit
};
};