Skip to content

Commit

Permalink
Comment changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblurie29 committed Feb 9, 2024
1 parent b77d89f commit 2673c8c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/controllers/Passenger.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const getAllPassengersForUser = async (req: Request, res: Response) => {
// make a call to AirTable to get all passengers for the user
await base('Passengers').find(
id.toString(),
async function (err: any, record: any | undefined) {
async (err: any, record: any | undefined) => {
if (err) {
logger.error(err);
return;
Expand All @@ -46,21 +46,25 @@ export const getAllPassengersForUser = async (req: Request, res: Response) => {
const accompanyingPassengersPromise = record._rawJson.fields[
'Related Accompanying Passenger(s)'
].map(async (id: string) => {
// map through the related passengers and get the passenger information for each one
const passenger = await base('Passengers').find(id.toString());
accompPassengers.push(passenger);
});

// Remove any unnecessary data from the passengers
await Promise.all(accompanyingPassengersPromise);
const trimmedPassengers = accompPassengers.map(
(passenger: Record<FieldSet>) =>
trimPassenger(passenger._rawJson as unknown as PassengerData)
);

// return the passengers for the user
return res.send(trimmedPassengers);
}
}
);
} catch (err: any) {
// if that fails return a 500 (hint, use try/catch)
// if that fails return a 500
console.error(err);
return res.status(500).json({ error: 'Error fetching record' });
}
Expand Down

0 comments on commit 2673c8c

Please sign in to comment.