33 lines
762 B
JavaScript
33 lines
762 B
JavaScript
import axios from 'axios';
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import config from '../config';
|
|
import {getAbsEntityCount} from '../utils/axios-utils';
|
|
|
|
export default function AbsEntityCount() {
|
|
|
|
const [absEntityCount, setAbsCount] = useState(null);
|
|
|
|
const handleAbsEntityCount = async () => {
|
|
let absEntityCount = null;
|
|
try {
|
|
absEntityCount = await getAbsEntityCount(`${config.API}stops-count`);
|
|
} catch (err) {
|
|
console.error('handleAbsEntityCount(): err.message: ' + err.message);
|
|
}
|
|
setAbsCount(absEntityCount);
|
|
};
|
|
|
|
useEffect(() => {
|
|
handleAbsEntityCount();
|
|
}, []);
|
|
|
|
return (
|
|
<>
|
|
<p>
|
|
Abs Count: {absEntityCount ? absEntityCount : 'loading...'}
|
|
</p>
|
|
</>
|
|
);
|
|
};
|