Reference API URL from Environment Variables in `Recycle.js`
Closed this issue · 0 comments
lugenx commented
In our ecohabit/client/src/components/Recycle.js
file, we currently have the API URL hardcoded. For better maintainability and flexibility, we'd like to reference this URL from our environment variables.
Task:
- Locate the
Recycle.js
file inecohabit/client/src/components/
. - Find the hardcoded URL:
https://api.ecohabit.org/recyclingcenters/country/${country}/postal/${postal}
. - Replace the hardcoded domain part of the URL (
https://api.ecohabit.org
) withprocess.env.REACT_APP_API_URL
. - Ensure that the final API call looks something like this:
`${process.env.REACT_APP_API_URL}/recyclingcenters/country/${country}/postal/${postal}`
- Create a pull request with your changes. Please ensure that the only modification is the URL update.
Tips:
- Make sure you have set up your local environment correctly and have the
.env
file configured based on.env.example
. - After making the change, test locally to ensure the app still fetches data as expected with the environment-based URL.