handle missing token issues
This commit is contained in:
@@ -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(() => []);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user