adding next.js app which calls the fastAPI AND displays date in the app.

This commit is contained in:
lucas.oskorep
2023-07-10 21:21:41 -04:00
parent aad7babb2c
commit d24a340c15
6 changed files with 46 additions and 29 deletions

View File

@@ -0,0 +1,19 @@
import {MtaData, MtaStartTime} from "@/services/mta-api/types";
export const fetchStationData = async (stations: [string]): Promise<MtaData> => {
const res = await fetch("/api/mta_data", {method: "POST"})
const data = await res.json()
return {
mtaData: data
};
};
export const fetchStartDate = async (stations: [string]): Promise<MtaStartTime> => {
const res = await fetch("/api/start_time", {method: "POST"})
const data = await res.text()
const date = new Date(data.replaceAll("\"", ""))
return {
startTime: date
};
};

View File

@@ -0,0 +1,7 @@
export interface MtaData {
mtaData: any;
};
export interface MtaStartTime {
startTime: Date
}