airport.ts 543 B

12345678910111213141516171819
  1. import axios from 'axios';
  2. import { Configuration } from './configuration';
  3. import { AirportOverview } from '../types';
  4. export class Airport {
  5. static async all(): Promise<AirportOverview[]> {
  6. const token = sessionStorage.getItem('token');
  7. if (!token) return [];
  8. return axios
  9. .get<AirportOverview[]>(`${Configuration.resourceServer}/airport/all`, {
  10. headers: {
  11. Authorization: `Bearer ${token}`,
  12. },
  13. })
  14. .then((response) => response.data)
  15. .catch(() => []);
  16. }
  17. }