diff --git a/frontend/src/routes/articles/+page.js b/frontend/src/routes/articles/+page.js new file mode 100644 index 0000000..9ec8383 --- /dev/null +++ b/frontend/src/routes/articles/+page.js @@ -0,0 +1,31 @@ +// Server Side Rendering + +export async function load(context) { + async function fetchData(data) { + try { + const resTemp = await context.fetch(`http://0.0.0.0:8000/${data}`); + if (resTemp.ok == false) { + return { + status: resTemp.status, + } + } + return { + status: 0, data: await resTemp.json(), + } + } catch (error) { + return { + status: 500, + } + } + } + + const res = (await fetchData(`get_simple_posts/4`)); + if (res.status == 500) return { + status: res.status + } + + return { + status: 0, + content: res.data, + }; +} \ No newline at end of file diff --git a/frontend/src/routes/articles/+page.svelte b/frontend/src/routes/articles/+page.svelte index c9887ef..f6ee807 100644 --- a/frontend/src/routes/articles/+page.svelte +++ b/frontend/src/routes/articles/+page.svelte @@ -1,34 +1,20 @@
Loading failed :c
{:else} -Loading...
+Loading failed :c
{/if}