♻️ Refactor backend and add comments
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import axios from "axios";
|
||||
const baseurl = "https://mobileapi.dsbcontrol.de";
|
||||
const baseUrl = "https://mobileapi.dsbcontrol.de";
|
||||
|
||||
export async function getAuthtoken(username, password) {
|
||||
const response = await axios.get(
|
||||
`${baseurl}/authid?user=${username}&password=${password}&bundleid&appversion&osversion&pushid`
|
||||
`${baseUrl}/authid?user=${username}&password=${password}&bundleid&appversion&osversion&pushid`
|
||||
);
|
||||
if (response.data == "") throw "Wrong username or password";
|
||||
return response.data;
|
||||
@ -11,13 +11,15 @@ export async function getAuthtoken(username, password) {
|
||||
|
||||
export async function getTimetables(authtoken) {
|
||||
const response = await axios.get(
|
||||
`${baseurl}/dsbtimetables?authid=${authtoken}`
|
||||
`${baseUrl}/dsbtimetables?authid=${authtoken}`
|
||||
);
|
||||
const timetables = response.data;
|
||||
|
||||
const urls = [];
|
||||
timetables.forEach((timetable) => {
|
||||
const rawTimestamp = timetable.Date;
|
||||
// Convert the timestamp to the correct
|
||||
// format so new Date() accepts it
|
||||
const date = rawTimestamp.split(" ")[0].split(".").reverse().join("-");
|
||||
const time = rawTimestamp.split(" ")[1];
|
||||
const timestamp = date + " " + time;
|
||||
|
Reference in New Issue
Block a user