【问题标题】:send data to a server FLUTTER将数据发送到服务器 FLUTTER
【发布时间】:2020-11-01 15:25:18
【问题描述】:
【问题讨论】:
标签:
json
database
api
flutter
server
【解决方案1】:
端点http://ec2-52-47-176-18.eu-west-3.compute.amazonaws.com/reg/us/ 不支持application/json 内容类型。根据this stackoverflow answer http 包只有 3 种类型:String、List 或 Map。试试这个:
var mapData = new Map<String, dynamic>();
mapData['firstname'] = firstname;
mapData['lastname'] = lastname;
mapData['username'] = username;
mapData['email'] = 'email;
mapData['passw'] = passw;
map['user_type'] = 'Administrador';
final http.Response response = await http.post(
'http://ec2-52-47-176-18.eu-west-3.compute.amazonaws.com/reg/us/',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: mapData
),
);
也是安全方面的。在处理用户信息时,例如姓名、密码和电子邮件。 请使用 HTTPS。您可以在 AWS 上通过在 API 服务器前面放置一个负载均衡器来实现这一点。