allocation.js 622 B

123456789101112131415161718192021222324
  1. import axios from 'axios';
  2. import { useLocation } from 'react-router';
  3. const env = process.env;
  4. class AllocationService {
  5. BASE_URL = process.env.BASE_URL || 'http://localhost:9090/allocation';
  6. async fetchAllocation(win, aggregate, options) {
  7. const { accumulate, filters, } = options;
  8. const params = {
  9. window: win,
  10. aggregate: aggregate,
  11. step: '1d',
  12. };
  13. if (typeof accumulate === 'boolean') {
  14. params.accumulate = accumulate;
  15. }
  16. const result = await axios.get(`${this.BASE_URL}/compute`, { params });
  17. return result.data;
  18. }
  19. }
  20. export default new AllocationService();