【发布时间】:2019-05-16 10:53:41
【问题描述】:
我想用以下代码在 Flutter 中发出一个 post 请求:
// Body: {"email": "example@email.com", "pass": "passw0rd"}
Future<dynamic> post(String url, var body) async {
var response = await http.post(url, body: body);
final String res = response.body;
return res;
}
// That's not the full code. I removed some lines because they are useless for this thread.
// Most of them are only some debug outputs or conditional statements
问题是我的发布请求不包括我的请求正文。我在我的服务器上检查了一些输出。
【问题讨论】:
-
尝试将请求发送到
httpbin.org/post,这将回显请求。也许您缺少请求标头。您可以使用 curl 或 Postman 执行有效的帖子吗?