Is there a way to switch api url from development to production

The name of the picture


Is there a way to switch api url from development to production



I am currently building an app using react native. And I have quite a few screens in it. As the app is still in development stage I still hit localhost now. I am wondering if there is a way to switch these url's programmatically while developing vs in production. Also considering that developing still continues even after the app is published and in the play store. How do anyone handle this scenario? Or am I thinking it in the wrong way?





This may help you github.com/luggit/react-native-config .
– Ashwin Mothilal
5 hours ago





Thanks, I think I can mix both yours and CrazyVK answer to make it work for me.
– Kireeti K
5 hours ago




1 Answer
1



Try this code:


var url = '';

if (__DEV__) {
url = 'http://localhost';
} else {
url = 'http://exmple.com';
}





Ah! great, thanks.
– Kireeti K
5 hours ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP