-
Notifications
You must be signed in to change notification settings - Fork 91
Lf 4281 migrate current weather api call to backend #3729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: integration
Are you sure you want to change the base?
Lf 4281 migrate current weather api call to backend #3729
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few suggestions but looks really good overall, thank you so much again for helping improve this
try { | ||
const farm_id = req.headers['farm_id']; | ||
const row = await baseController.getIndividual(FarmModel, farm_id); | ||
|
||
if (!row.length) { | ||
return res.sendStatus(404); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a method called getFarmByID
in the farm controller that does exactly this except it gets the farm from the params, could we update that one to read either from params or from the header? I also think that method should probably just return the single row instead of an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function getFarmByID
also uses await baseController.getIndividual(FarmModel, id);
so the result would be same. I have updated the code to use array de-structure rather than index to make it cleaner.
Description
This PR introduces a new endpoint to provide weather information for the farm. Previously, the frontend directly called the OpenWeather API, exposing API keys. Now, all logic is handled securely behind this endpoint. Additionally, this PR updates the frontend to use the correct RTK Query endpoint for fetching weather data.
Jira link:https://lite-farm.atlassian.net/browse/LF-4281
Type of change
How Has This Been Tested?
Login with your credentials and select farm. On landing page, weather information is shown.
Checklist: