【发布时间】:2021-07-04 08:43:40
【问题描述】:
loginUser(email, password) async {
var url = Uri.parse
.call("https://us-central1-agenie-webapp.cloudfunctions.net/api/login");
final http.Response response = await http.post(
url,
headers: <String, String>{
'Content-Type': 'application/json',
},
body: jsonEncode(<String, String>{'email': email, 'password': password}),
);
if (response.statusCode == 200) return response.body;
return null;
}
这是 api post 调用,当我在 web localhost 上使用 flutter run 运行它时,当我点击登录按钮调用此函数时,按下它会在 vscode 中打开一个名为 browser_client.dart 的窗口并转到第 69 行它显示:
unawaited(xhr.onError.first.then((_) {
// Unfortunately, the underlying XMLHttpRequest API doesn't expose any
// specific information about the error itself.
completer.completeError(
ClientException('XMLHttpRequest error.', request.url),
StackTrace.current);
}));
有什么解决办法吗?谢谢
【问题讨论】: