如何在Interceptorwrapper中传递onRequest
requestInterceptor(RequestOptions options) async {
options.headers["Content-Type"] = "application/x-www-form-urlencoded";
return options;
在此
dio.interceptors.add(
InterceptorsWrapper(
onRequest: (RequestOptions options) => requestInterceptor(options),
),
);
之前工作正常,但现在错误出现为错误:参数类型“dynamic Function(RequestOptions)”无法分配给参数类型“void Function(RequestOptions, RequestInterceptorHandler)” 如果我在函数中添加处理程序错误,我必须做什么:无法将参数类型“dynamic Function(RequestOptions)”分配给参数类型“void Function(RequestOptions, RequestInterceptorHandler)”,它也给出了如何解决这个问题 请帮忙
requestInterceptor(RequestOptions options) async {
options.headers["Content-Type"] = "application/x-www-form-urlencoded";
return options;
}
dio.interceptors.add(
InterceptorsWrapper(
onRequest: (RequestOptions options) => requestInterceptor(options),
),
);
before this was working fine but now the error is coming as error: The argument type 'dynamic Function(RequestOptions)' can't be assigned to the parameter type 'void Function(RequestOptions, RequestInterceptorHandler)'
what I have to do if I add handler in the functions error: The argument type 'dynamic Function(RequestOptions)' can't be assigned to the parameter type 'void Function(RequestOptions, RequestInterceptorHandler)' its too gives how to solve this
please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在
onRequest
中使用RequestInterceptorHandler
并将选项发送(下一步)到处理程序。Try to use
RequestInterceptorHandler
inonRequest
and send (next) the option to the hander.