【发布时间】:2020-11-25 10:45:33
【问题描述】:
我对@987654322@ 很陌生,遇到了以下问题:
child: RaisedButton(
onPressed: () {
fetchData();
},
// ...
fetchData() async {
final res = await http.get("https://jsonplaceholder.typicode.com/posts");
if (res.statusCode == 200) {
// If the call to the server was successful, parse the JSON
print("it works");
return json.decode(res.body);
} else {
// If that call was not successful, throw an error.
throw Exception('Failed to load post');
}
}
// ...
当我删除 http.get 部分时,它会打印“它可以工作”,所以我认为问题出在 http.get 执行中。
【问题讨论】:
-
需要更多解释,它会抛出错误
Failed to load post?? -
不,没有什么事情发生
-
尝试 curl 或 postman 获取相同的 url,发布结果
-
邮递员的邮件标题详细信息