lugenx/ecohabit

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:

  1. Locate the Recycle.js file in ecohabit/client/src/components/.
  2. Find the hardcoded URL: https://api.ecohabit.org/recyclingcenters/country/${country}/postal/${postal}.
  3. Replace the hardcoded domain part of the URL (https://api.ecohabit.org) with process.env.REACT_APP_API_URL.
  4. Ensure that the final API call looks something like this:
`${process.env.REACT_APP_API_URL}/recyclingcenters/country/${country}/postal/${postal}`
  1. 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.