Frontend: Reading from backend pictures.
This commit is contained in:
parent
64818f0970
commit
7549aa7bea
2 changed files with 34 additions and 1 deletions
31
frontend/src/routes/+page.server.js
Normal file
31
frontend/src/routes/+page.server.js
Normal file
|
@ -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:8085/${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("photo_list"));
|
||||
if (res.status == 500) return {
|
||||
status: res.status
|
||||
}
|
||||
|
||||
return {
|
||||
status: 0,
|
||||
content: res.data,
|
||||
};
|
||||
}
|
|
@ -18,7 +18,9 @@
|
|||
import SvgIcon from "@jamescoyle/svelte-icon/src/svg-icon.svelte";
|
||||
import { mdiChevronRight, mdiChevronLeft } from "@mdi/js";
|
||||
|
||||
let photoList = filterPhotos(hubjson.photos);
|
||||
export let data;
|
||||
const photoData = data.status == 0 ? data : undefined;
|
||||
let photoList = filterPhotos(photoData.content);
|
||||
$: index = 0;
|
||||
let photoDiv;
|
||||
let tempPhotoDiv;
|
||||
|
|
Loading…
Add table
Reference in a new issue