React Native: fetch request failed with error - TypeError: Network request failed(…)

前端 未结 2 1494
日久生厌
日久生厌 2020-12-15 22:00

I am developing a simple app using React Native. I am testing it on Android device. I have created a Node.js server to listen to the requests, it is running at http://localh

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 22:35

    Use the reverse command of the Android Debug Bridge tool (adb):

    adb reverse   - reverse socket connections.
                                   reverse specs are one of:
                                     tcp:
                                     localabstract:
                                     localreserved:
                                     localfilesystem:
    

    For example:

    adb reverse tcp:3333 tcp:3333
    

    This makes localhost:3333 accessible from your device. You can also use different ports. For example:

    adb reverse tcp:8081 tcp:3333
    

    This will redirect the device port 8081 to the local port 3333.

提交回复
热议问题