React-Native fetch through proxy

2019-06-15 07:05发布

问题:

How can I set options in the fetch method of react-native to make a call to a webserver go through a proxy.

Currently I am using axios but this doesn't work.

After adding a host header to the fetch, I can make a request through charles-proxy but it doesn't work with squid. (Error: invalid url).

回答1:

Hello You can use this module node-fetch(https://github.com/bitinn/node-fetch) and set agent param for proxy,

For more details, you can also check this https://github.com/bitinn/node-fetch/issues/79