Skip to content

Commit

Permalink
Call cached data first
Browse files Browse the repository at this point in the history
  • Loading branch information
ddxv committed Dec 12, 2024
1 parent fc4c677 commit 575ce8f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export const csr: boolean = true;

export const load: PageServerLoad = async ({ params, parent }) => {
console.log(`start load overview for companies in ${params.category}`);
const res = fetch(`http://localhost:8000/api/companies/categories/${params.category}`);

const { appCats } = await parent();
const res = fetch(`http://localhost:8000/api/companies/categories/${params.category}`);

try {
return {
appCats: await appCats,
companiesOverview: res
.then((resp) => {
if (resp.status === 200) {
Expand All @@ -30,8 +30,7 @@ export const load: PageServerLoad = async ({ params, parent }) => {
console.log('Uncaught error', error);
return 'Uncaught Error';
}
),
appCats: await appCats
)
};
} catch (error) {
console.error('Failed to load data:', error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ export const ssr: boolean = true;
export const csr: boolean = true;

export const load: PageServerLoad = async ({ params, parent }) => {
const { appCats } = await parent();
const res = fetch(
`http://localhost:8000/api/companies/types/${params.type}?category=${params.category}`
);

const { appCats } = await parent();

try {
return {
companiesOverview: res
Expand Down

0 comments on commit 575ce8f

Please sign in to comment.