从Flutter应用发出Https请求?

时间:2020-04-28 13:36:14

标签: api http flutter dart https

我已将我的API部署在服务器中,并且可以通过HTTP,https请求之一来访问API。 我已经通过发出http请求测试了api。喜欢

String loginURL="https://<ip>/login/auth";
http.Response response = await http.post(loginURL,
          headers: {"Content-type": "application/json"},
          body: json.encode({"username": username, "password": password}));

如果我完成了http请求,我将获得成功代码为200的响应

但是当我尝试使用与https一起部署的相同API时。我在服务器未收到任何响应的情况下得到异常。如何发出https请求?

1 个答案:

答案 0 :(得分:0)

使用此HTTP模板

#next

This link will also help