handle missing token issues

This commit is contained in:
Sven Czarnian
2022-11-04 15:27:55 +01:00
parent 5bca340bdd
commit ecc01fbb8c

View File

@@ -4,12 +4,16 @@ import { AirportOverview } from '../types';
export class Airport {
static async all(): Promise<AirportOverview[]> {
const token = sessionStorage.getItem('token');
if (!token) return [];
return axios
.get<AirportOverview[]>(`${Configuration.resourceServer}/airport/all`, {
headers: {
Authorization: `Bearer ${sessionStorage.getItem('token')}`,
Authorization: `Bearer ${token}`,
},
})
.then((response) => response.data);
.then((response) => response.data)
.catch(() => []);
}
}
}