Setting up environment variables for React Ionic Capacitor app
Hello everyone, in this tutorial we are going to learn how can we use environment variable in React-Capacitor mobile app. If you want to set up react-capacitor application, please refer to this article : How to Make a Mobile App with React, Ionic and Capacitor Let's walkthrough the App.js code, which only consists of a button ,clicking on that button app calls an endpoint. import React from 'react' ; import axios from 'axios' ; const App = () => { const getData = () => { console . log ( "Current environment : " , process . env . NODE_ENV ) axios . post ( `${process.env.PUBLIC_URL}/getdata` ) . then ( response => console . log ( response )) . catch ( err => console . log ( err )) } return ( < div > < button onClick = { getData } > Get Data </ button > </ div > ); } export default App ; In this example, process.env.VAR_NAME is...