Skip to content

Commit

Permalink
fix: history promise
Browse files Browse the repository at this point in the history
  • Loading branch information
MSchmoecker committed Nov 26, 2024
1 parent 9471355 commit c5d0f12
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions frontend/src/routes/(authenticated)/history/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import type { Commit } from '$lib/history';
import type { PageLoad } from './$types';

export const load = (async ({ fetch }) => {
const response = await fetch(`/api/history`, {
const history_response = fetch(`/api/history`, {
method: 'GET',
headers: {
'content-type': 'application/json'
}
}).then((res) => {
if (!res.ok) {
throw new Error(`Failed to fetch history: ${res.status} ${res.statusText}`);
}
return res.json() as Promise<Commit[]>;
});
return {
history: response.json() as Promise<Commit[]>
history: history_response
};
}) satisfies PageLoad;

0 comments on commit c5d0f12

Please sign in to comment.