美文网首页
react-native 使用fatch,网络请求踩坑记录

react-native 使用fatch,网络请求踩坑记录

作者: Mrmcling | 来源:发表于2020-08-12 16:25 被阅读0次

问题1:
不管怎么请求,console无打印信息,也没有请求的记录。当时我使用的chrome作为debug工具。(chrome是捕捉不到请求的,所以显示不出来。)
解决办法:换个工具Reactotron,使用方法(https://blog.csdn.net/qq_34273059/article/details/100124501?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param

问题2:
post请求一直异常
解决办法:
1.模拟器添加dns
emulator @你模拟器的名字 -dns-server 8.8.8.8,114.114.114.114

2.headers中添加参数:'Content-Type': 'application/x-www-form-urlencoded'

相关文章

网友评论

      本文标题:react-native 使用fatch,网络请求踩坑记录

      本文链接:https://www.haomeiwen.com/subject/rxkmdktx.html