LDB Adjustments

This commit is contained in:
Fred Boniface 2023-06-14 00:43:06 +01:00
parent 5b53c9f51e
commit efa510fc28
2 changed files with 12 additions and 4 deletions

View File

@ -1,4 +1,4 @@
from node:latest AS build FROM node:latest AS build
WORKDIR /app WORKDIR /app
COPY package.json / COPY package.json /

View File

@ -11,11 +11,17 @@
return new URLSearchParams(window.location.search).get('station'); return new URLSearchParams(window.location.search).get('station');
} }
/**
* @type {any[]}
*/
let jsonData = [] // Extract train data from the object to pass to #each
onMount(async () => { onMount(async () => {
const station = await getHeadcode(); const station = await getHeadcode();
document.getElementById('station').textContent = station; document.getElementById('station').textContent = station;
const data = await fetch(`https://owlboard.info/api/v1/ldb/${station}`) const data = await fetch(`https://owlboard.info/api/v1/ldb/${station}`);
document.getElementById('data_raw').textContent = JSON.stringify(await data.json()); const jsonData = await data.json();
//document.getElementById('data_raw').textContent = JSON.stringify(await data.json());
}) })
</script> </script>
@ -23,7 +29,9 @@
<Menu {title} /> <Menu {title} />
<p>Station: <span id="station"></span></p> <p>Station: <span id="station"></span></p>
<p id="data_raw"></p> {#each jsonData as item}
<p>{item.GetStationBoardResult.trainServices.operator}</p>
{/each}
<Footer {page} /> <Footer {page} />