adding next.js app which calls the fastAPI AND displays date in the app.
This commit is contained in:
19
mta-sign-ui/services/mta-api/mta-server.ts
Normal file
19
mta-sign-ui/services/mta-api/mta-server.ts
Normal 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
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user