import React, { useState, useEffect } from "react"; import * as api from "../services/api"; function Home() { const [loadingData, setLoadingData] = useState(true); const [data, setData] = useState([]); const apiUrl = `${api.getApiBaseUrl()}solutions`; const requestOptions = { method: 'GET', headers: { 'Content-Type': 'application/json' }, }; useEffect(() => { async function getData() { fetch(apiUrl, requestOptions) .then(res => res.json()) .then( (result) => { console.log('routes found from api call', result); setData(result); setLoadingData(false); }, (error) => { console.log('*** ERROR!', error); } ) } if (loadingData) { getData(); } }, []); function handleRowClick(id, vehicleId) { console.log('navigate to ', id, vehicleId); window.location.href = `http://localhost:3000/route?id=${id}&vehicleId=${vehicleId}`; } return (
Loading Please wait...
) : (Route | Date | Tours | Vehicles |
---|---|---|---|
{route.id} | {route.date} | {route.vehicles.length} |
|