handle missing token issues
This commit is contained in:
		| @@ -4,12 +4,16 @@ import { AirportOverview } from '../types'; | |||||||
|  |  | ||||||
| export class Airport { | export class Airport { | ||||||
|   static async all(): Promise<AirportOverview[]> { |   static async all(): Promise<AirportOverview[]> { | ||||||
|  |     const token = sessionStorage.getItem('token'); | ||||||
|  |     if (!token) return []; | ||||||
|  |  | ||||||
|     return axios |     return axios | ||||||
|       .get<AirportOverview[]>(`${Configuration.resourceServer}/airport/all`, { |       .get<AirportOverview[]>(`${Configuration.resourceServer}/airport/all`, { | ||||||
|         headers: { |         headers: { | ||||||
|           Authorization: `Bearer ${sessionStorage.getItem('token')}`, |           Authorization: `Bearer ${token}`, | ||||||
|         }, |         }, | ||||||
|       }) |       }) | ||||||
|       .then((response) => response.data); |       .then((response) => response.data) | ||||||
|  |       .catch(() => []); | ||||||
|   } |   } | ||||||
| } | } | ||||||
		Reference in New Issue
	
	Block a user