flutter - 如何将函数中的参数用于带有 Dio 包的 http 请求正文
问题描述
Future<void> login(String email, String password) async {
String url = "https://phone-book-api.herokuapp.com/api/v1/signin";
Response response;
var dio = Dio();
response = await dio.post(url,
data: {"email": email, "password": password);
print(response.data);
}
如果我使用上面的代码创建函数,我会遇到一些错误,但是如果我用硬代码填充正文,则不会发生错误,并且我可以在代码示例下方收到响应
Future<void> login(String email, String password) async {
String url = "https://phone-book-api.herokuapp.com/api/v1/signin";
Response response;
var dio = Dio();
response = await dio.post(url,
data: {"email": "l200140004@gmail.com", "password": "l200140004");
print(response.data);
}
任何人都可以帮助我并向我解释它的情况,请...
解决方案
对不起大家,我的密码输入错误,所以可能是错误的
推荐阅读
- c - 为什么我的 c 函数 translate() 返回随机符号?
- python - pymongo 错误名称“ISODate”未定义
- angular - chrome devtools 中的 ES6 导入
- machine-learning - Keras:如何在训练和测试阶段使用 dropout?
- postman - 如何访问测试字段中的环境变量
- entity-framework - 从数据库中获取 int 值
- android - 我制作了一个添加两个数字的应用程序,但是当编辑文本为空并且按下按钮时应用程序不断停止
- ios - 点击 UICollectionView 时更改单元格颜色
- xml - 重复列表的 XML 解析
- jquery - 从 Jquery 获取数字输入的值,使用 nicenumber() 进行数字输入