I'm trying to call "https" localhost server from Expo React Native app. But i'm getting "Network Error". How to call https server in React Native?
Initialise baseUrl in React Native =>
baseUrl = Platform.OS === "ios" ? "https://localhost:1999" : "https://10.0.2.2:1999"
CodePudding user response:
If I understand your question correctly try typing
npm start
in your terminal. Then after that it will prompt you with a choice to either run it in an emulator or on web. all you have to do is hit 'w' on your keyboard. That should run it in your default browser.
Starting Metro Bundler
› Metro waiting on [ip]
› Linking is disabled because the client scheme cannot be resolved.
› Press a │ open Android
› Press i │ open iOS simulator
› Press w │ open web
› Press r │ reload app
› Press m │ toggle menu
› Press d │ show developer tools
› shift d │ toggle auto opening developer tools on startup (disabled)
› Press ? │ show all commands
just hit 'w' after this console message
CodePudding user response:
If you are developing your app in pc and trying to view app in mobile phone, you should not use "localhost" instead
connect to same LAN, hotspot
If on windows -
- goto cmd
- type "ipconfig"
- goto ipv4 address it looks like ("192.168.178.43")
- this is written instead of localhost in mobile
- put : after it and write port number
- your url will look like 192.168.178.43:1999
if on linux/mac - -go to bash/fish/zsh -type "ifconfig" -do the same as in linux