Open smackeem opened 10 months ago
While keeping things DRY is important I'd say if you're only dealing with two functions, it may not be worth refactoring it into a single function. But you've already identified how it could be done, and if you did take the time, then your approach makes sense to me.
This code block looks good to me, it has error handling built in and it's understandable.
I couldn't find very much to improve upon:
getRoudTrip
When communicating with the API, the url is created by appending the key value pairs to the base URL and sending a GET request as well as an Access token. The difference between getting a OneWay Ticket and a Round trip is adding a return date to the URL. So to improve this I would have the one route service both requests with a helper function to filter out the body and add to base URL. Otherwise, my backend is pretty solid.
This is the same request for getRoundWayTrip so I would want to make it just one but if a returnDate property exists, then append it to URL otherwise don't.