flutter - “如何使用 Flutter 以最简单的方式调用带有登录凭据(如用户名和密码)的 post api”
问题描述
如何使用登录凭证(如用户名和密码)以最简单的方式使用 Flutter 调用 post api 请让我知道在 Flutter 中调用 post api 的数量。
解决方案
通过使用以下方法,您可以在标题或正文中发送数据。
new http.Client()
.post(url, headers: {'Content-type': 'application/json','username':'****','password':'****'},
body: JSON.encoder.convert({'username':'****','password':'****'}))
.then((http.Response r) => r.body)
.whenComplete(() => print('completed'));
推荐阅读
- npm - 如何更改documentation.js 中的主题?
- windows - 部署时 WIX MSI 应用程序未在用户帐户下启动应用程序
- laravel - 未找到 Laravel 特征函数
- ios - YTPlayer 以特定帧宽和高播放视频
- java - 使用 AJAX 向 Spring 控制器发送数据
- sql - 跨多行的 SQL Lag()
- vba - 使用 Excel VBA 将多个电子表格有效地导入到一张主表中
- c++ - 我将我的编译器从 32 转换为 64 位,但我仍然不能使用超过 2GB :( 为什么?
- java - String [] words = s.split("[^a-zA-Z]+");
- ios - 调用 UICollectionView.reloadData() 冻结应用程序