本文介绍了我们如何调试/查看通过Moya通过API设置的请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何调试正在设置到后端服务器的请求?
How do we debug the request being set over to backend servers?
我希望能够准确地看到或打印出带有标头参数的完整请求,等等...每当我按Moya
I'd like to be able to see exactly or print out the full request with headers parameters, etc... that is being sent over to servers whenever I make any request by Moya
推荐答案
这是通过激活Moya
已经拥有的插件来完成的.它是NetworkLoggerPlugin
.我需要更改以下代码行:
It is done by activating a plugin that Moya
Already has it. it is NetworkLoggerPlugin
. I need to change this line of code:
var provider = MoyaProvider<MainAPI>()
具有:
var provider = MoyaProvider<MainAPI>(plugins: [NetworkLoggerPlugin(verbose: true)])
感谢@ Anbu.Karthik
Thanks to @Anbu.Karthik
这篇关于我们如何调试/查看通过Moya通过API设置的请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!