diff --git a/pages/index.tsx b/pages/index.tsx index 0121aa6..bcdf01c 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -31,7 +31,7 @@ export const getServerSideProps: GetServerSideProps = async ( try { const googleMapsApiKey = process.env.GOOGLE_MAPS_API_KEY; const webSocketURL = process.env.WEBSOCKET_URL; - const currentBoats = await fetchBoats(); + const currentBoats = await fetchBoats(process.env.BASE_URL); if (!googleMapsApiKey) { throw new Error('Environment variable not set: GOOGLE_MAPS_API_KEY'); @@ -74,8 +74,8 @@ const parseBoat = (deviceSample: any): Boat => { }; }; -const fetchBoats = async () => { - const data = await axios.get(`${process.env.BASE_URL}/api/external-samples?lastHour=true`, {}); +const fetchBoats = async (baseUrl: any) => { + const data = await axios.get(`${baseUrl}/api/external-samples?lastHour=true`, {}); return JSON.parse(JSON.stringify( data.data.samples.map((sample: any) => parseBoat({ ...sample, name: sample.device.name })))); }; @@ -112,8 +112,9 @@ const MapWithVehicles: NextPage = ({ useEffect(() => { const interval = setInterval(async () => { - const newBoats = await fetchBoats() + const newBoats = await fetchBoats("") setBoats(newBoats) + console.log(newBoats) }, 20000); return () => clearInterval(interval); }, []);