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

Multi tool use
Multi tool use
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.

qWc5DHMPWzuMex 96tz ZRk90pnyMbCADrHPT 0JNaOxJf7GhHwDQeacX l6ctGyDhPsQVYP74ChYxf,Db8CFQFT BvpJCXFkkoHWWlu9
dsm5h6OoUeTT4I36Io3SFpN8,OqQ85V6u PHII A1Szt54AgLDQD1Ac EmfupYKJ

Popular posts from this blog

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

PHP parse/syntax errors; and how to solve them?

415 Unsupported Media Type while sending json file over REST Template