How do I inspect network traffic on a react native

2019-02-20 14:19发布

I'm using the latest React Native (0.18 at the time of this writing) and would like to inspect the network requests my iOS simulator makes. Using the latest Xcode "instruments" i get this: enter image description here . I get the same error on both 10.11 and 10.10 machines, both using the latest Xcode.

I've also tried using Charles, but it's unable to intercept the traffic. Wireshark is able to see it, but the data I'm after is SSL based, so I cannot access it.

As a webdeveloper, ideally I'd like to inspect network traffic in my chrome debugger, but I understand that this cannot be possible in this kind of environment, but simply looking at raw packet data is not userfriendly enough for debugging purposes.

Who knows of a solution for this?

2条回答
冷血范
2楼-- · 2019-02-20 14:47

Turns out using Charles is a good option.

Just set up the SSL certificates: Help > SSL Proxying > Install Charles Root Certificate in iOS Simulators) in charles and be happy!

查看更多
戒情不戒烟
3楼-- · 2019-02-20 14:48

Actually, now you can view network traffic using the react native network inspector introduced in version 0.33. I demo how to use the inspector in my video on how to make network requests in react native (starting at 1:46) http://codecookbook.co/post/how-to-make-network-requests-in-react-native/

查看更多
登录 后发表回答