Skip to content

Commit

Permalink
fix: tracked down why it took 2x as much on SSR to load api
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksasiriski committed Nov 9, 2023
1 parent f5a38e6 commit 89c8d9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prednjica",
"version": "0.3.0",
"version": "0.3.2",
"private": true,
"scripts": {
"start": "node ./index.js",
Expand Down
11 changes: 10 additions & 1 deletion src/routes/search/+page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import type { PageLoad } from './$types';
import { env } from '$env/dynamic/public';

export const load: PageLoad = async ({ fetch, url }) => {
export const load: PageLoad = async ({ data, fetch, url }) => {
// this runs on SSR (+page.server.ts)
if (data != null) {
return {
query: data.query,
results: data.results
};
}

// this runs on CSR
const q = url.searchParams.get('q');
if (q === null || q === '') {
return {
Expand Down

0 comments on commit 89c8d9a

Please sign in to comment.