Extract ui api requests to common functions
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import axios from 'axios';
|
||||
import { Airport } from './airport.types';
|
||||
import { Metar } from './metar.types';
|
||||
import { getRequest } from '.';
|
||||
|
||||
interface GetMetarsResponse {
|
||||
data: Metar[];
|
||||
@@ -11,7 +11,6 @@ export async function getMetars(airports: Airport[]): Promise<GetMetarsResponse>
|
||||
return { data: [] };
|
||||
}
|
||||
const stationICAOs: string = airports.map((airport) => airport.icao).join(',');
|
||||
const url = `http://localhost:5000/metars/${stationICAOs}`;
|
||||
const response = await axios.get(url).catch((error) => console.error(error));
|
||||
const response = await getRequest(`metars/${stationICAOs}`, {});
|
||||
return response?.data || { data: [] };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user