I'm trying to post data to node API from flutter. my code is as follows.
final String uri = "http://localhost:3000";
Map<String, String> userBody = {
"firstName":"Vishal",
"lastName":"Soni",
"email":"[email protected]",
"mobile":"1234567890",
"password":"123",
};
Future<dynamic> postData() async {
try {
http.Response res = await http.Client().post("$uri/register", body: jsonEncode(userBody), headers: {
'Content-Type': 'application/json',
});
print(res);
} catch (e) {
print(e);
}
}
