I tried to follow this: https://flutter.dev/docs/cookbook/networking/send-data but code it's not working and i dont know why. Can someone help me and tell me what I have wrong or some video I could use to implement those functions correctly?
What I want to do is to send all the information from a form to the server.
My code: https://github.com/guillemrh/urbix/blob/master/lib/screens/signup_screen_administrador.dart
Thank you
The endpoint http://ec2-52-47-176-18.eu-west-3.compute.amazonaws.com/reg/us/
does not support application/json
content type. According to this stackoverflow answer http package only has 3 types: String, List or Map. Try this:
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
),
);
Also security wise. When dealing with user information such as name, password, and email. Please use HTTPS . You can achieve this on AWS by throwing a load balancer in front of the API server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.