React-Native fetch through proxy

给你一囗甜甜゛ 提交于 2019-12-10 12:35:03

问题


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



来源:https://stackoverflow.com/questions/42674258/react-native-fetch-through-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!