61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
import axios from 'axios';
|
|
|
|
import config from './config';
|
|
|
|
/*
|
|
*get count of bus stops
|
|
*/
|
|
export async function getBusStopCount(){
|
|
//console.log('getBusStopCount() Start...');
|
|
|
|
let count=null;
|
|
try {
|
|
//TODO handle errors: https://www.valentinog.com/blog/await-react/
|
|
const address = `${config.API}bus-stop/count`;
|
|
const rsp = await axios.get(address);
|
|
count = rsp.data[0][0];
|
|
} catch (err) {
|
|
console.error('err.message: ' + err.message);
|
|
}
|
|
//console.log('getBusStopCount() Done.');
|
|
return count;
|
|
};
|
|
|
|
/*
|
|
*get count of train stations
|
|
*/
|
|
export async function getTrainStationCount(){
|
|
//console.log('getTrainStationCount() Start...');
|
|
|
|
let count=null;
|
|
try {
|
|
//TODO handle errors: https://www.valentinog.com/blog/await-react/
|
|
const address = `${config.API}train-station/count`;
|
|
const rsp = await axios.get(address);
|
|
count = rsp.data[0][0];
|
|
} catch (err) {
|
|
console.error('err.message: ' + err.message);
|
|
}
|
|
//console.log('getTrainStationCount() Done.');
|
|
return count;
|
|
};
|
|
|
|
/*
|
|
*get all train stations
|
|
*/
|
|
export async function getTrainStationInfo(){
|
|
//console.log('getTrainStationInfo() Start...');
|
|
|
|
let count=null;
|
|
try {
|
|
//TODO handle errors: https://www.valentinog.com/blog/await-react/
|
|
const address = `${config.API}train-station/count`;
|
|
const rsp = await axios.get(address);
|
|
console.log('getTrainStationInfo() rsp.length: ' +rsp.length);
|
|
} catch (err) {
|
|
console.error('err.message: ' + err.message);
|
|
}
|
|
//console.log('getTrainStationInfo() Done.');
|
|
return null;
|
|
};
|