I
I
Isaac Clark2019-07-28 00:27:00
JavaScript
Isaac Clark, 2019-07-28 00:27:00

How to get env variable?

Hello.
There is an env variable, on the command line, if you write it, echo $TEST,it displays data.
I need to get this variable for endPoint in the application in order to make requests.
Can you please tell me how to get this variable, what to use it further on the frontend?
The app uses webpack and React

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-07-28
@Dark_Knight

webpack.DefinePlugin

module.exports = {
  plugins: [
    new webpack.DefinePlugin({
      __API_URL__: JSON.stringify(process.env.API_URL),
    });
  ],
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question