-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.js
54 lines (49 loc) · 1.11 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import rp from "request-promise";
const getTrainInformation = (trainNo, callback) => {
rp(
`https://indian-railway-api.cyclic.app/trains/getTrain/?trainNo=${trainNo}`
)
.then((resp) => {
callback(resp);
})
.catch((err) => {
callback(err);
});
};
const getTrainBtwStation = (from, to, callback) => {
rp(
`https://indian-railway-api.cyclic.app/trains/betweenStations/?from=${from}&to=${to}`
)
.then((resp) => {
callback(resp);
})
.catch((err) => {
callback(err);
});
};
const getTrainOnDate = (from, to, date, callback) => {
rp(
`https://indian-railway-api.cyclic.app/trains/gettrainon?from=${from}&to=${to}&date=${date}`
)
.then((resp) => {
callback(resp);
})
.catch((err) => {
callback(err);
});
};
const getRoute = (trainNo, callback) => {
rp(`https://indian-railway-api.cyclic.app/trains/getRoute?trainNo=${trainNo}`)
.then((resp) => {
callback(resp);
})
.catch((err) => {
callback(err);
});
};
export default {
getTrainInformation,
getTrainBtwStation,
getTrainOnDate,
getRoute,
};