Error: Cannot access url.searchParams on a page with prerendering enabled in +server.ts
#6849
-
|
Am building a blog with mdsvex with an endpoint that can be called for a specific number of articles, with that number being specified as a query string, this works well in development with Removing the export const GET: RequestHandler = async ({url, params}) => {
try {
const limitParam = url.searchParams.get('limit');
const limit = limitParam ? parseInt(limitParam) : 6;
const articles = await fetchArticles(limit);
return json(articles);
} catch (err) {
console.log(err)
throw error(500, 'An error occurred while fetching the posts')
}
};This endpoint is in it's own Package info |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
From the docs:
https://kit.svelte.dev/docs/page-options#prerender-when-not-to-prerender As a side note, you only receive the error during build because pre-rendering only occurs during build. |
Beta Was this translation helpful? Give feedback.
From the docs:
https://kit.svelte.dev/docs/page-options#prerender-when-not-to-prerender
As a side note, you only receive the error during build because pre-rendering only occurs during build.