0

Hi all i have set the variable in environment file like as below

REACT_APP_RECIPIENT_MAIL="[email protected],[email protected],[email protected]"

and then i am retrieving those like as below

  let toArr;
  if (isDevelopmentMode()) {
    const mailList = process.env.REACT_APP_RECIPIENT_MAIL;
    console.log(mailList);
    toArr = mailList.split(',');
  } else {
    toArr = Array.isArray(to) ? to : [to];
  }
  const toAddrs = toArr.map(toAddr => ({
    emailAddress: {
      address: toAddr
    }
  })); 

getting undefined at this line console.log(mailList); for mailList and i am not sure where i am doing wrong with the above code, Could any one please suggest any ideas on this?

Many thanks in advance.

3
  • 1
    Did you stop the server and run npm start again after adding the env var? Commented Sep 15, 2020 at 20:04
  • many thanks for the quick response, it worked after did npm start Commented Sep 15, 2020 at 20:08
  • Cool, I also wrote it as an answer below Commented Sep 15, 2020 at 20:09

1 Answer 1

1

For the newly added env variables to be available, you need to stop React server and start it again with npm start.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.