flutter - 在 runtimeType 响应中访问数据: 迪奥错误
问题描述
我正在发送一个与 dio 库有关的请求
发现错误时,我可以print(e.response);
并且print(e.response.statusCode);
响应的 runtimeType 是Response<dynamic>
在打印响应时,我得到这样的东西
{"message":"there is message from the api here"}
我无法访问此消息来打印它。
我试过了
e.response.message and get
错误.dart:167Uncaught (in promise) Error: NoSuchMethodError: 'message'
e.response["message"]
并得到Uncaught (in promise) Error: NoSuchMethodError: '[]'
我尝试了 json.encoding e.response,它也不起作用,我怎样才能访问类型内的数据Response<dynamic>
谢谢
解决方案
改为使用e.response.data['...']
以访问您想要的数据,
推荐阅读
- python - django PermissionRequiredMixin permission_required 不起作用
- spring - MongoDB 聚合错误:引用无效
- python - glProgramUniformMatrix3fv 不能正常工作
- javascript - Javascript Object 按属性获取对象
- python - 神经网络对具有不同特征的不同实例做出相同的预测
- pip - Windows 10 上的 Anaconda 3 无法安装 pyinstaller - ssl 证书问题
- node.js - 如何从 npm 包中安装特定文件,例如仅从 bootstrap bootstrap.min.css?
- mysql - 仅从 1 行中选择和订购
- opencv - SolvePnp 不给出相同的结果与四个点和更多的点
- vb.net - 调试不进入类代码时使用“Step Into”