Calling locally hosted server from Expo App

后端 未结 7 756
无人共我
无人共我 2020-12-08 20:26

I am creating a react-native app and one of the components I have created contains a property which is populated through data coming from an http request.

Right now

7条回答
  •  半阙折子戏
    2020-12-08 20:59

    You should replace the http://localhost:3000/ address with the ip address of your computer.

    On windows, open a prompt and type ipconfig, check the line of your network interface and get the address IPV4, should look like 192.168.1.20. Then you can make your calls with fetch and an url looking like htt://192.168.1.20/routname.

    By the way, your computer (server) and your device must be on the same local network. Wifi and lan shares the same network.

提交回复
热议问题