I can't process the response from the server correctly in flutter. The user is created successfully in the database. In the postman application, I also get a response from the server: {"success":true}
. But for some reason a connection error is displayed in the console, although the user is also successfully created from the flutter in the table:
Future<void> _sendLanguages(List<String> selectedLanguages, String firstName, String lastName, String email, String password) async {
final url = Uri.parse('http://localhost/create_user.php');
final response = await http.post(
url,
headers: {"Content-Type": "application/json"},
body: jsonEncode({
'first_name': widget.firstName,
'last_name': widget.lastName,
'email': widget.email,
'password': widget.password,
'languages': _selectedLanguages.map((language) => language.code).toList(),
}),
);
final jsonResponse = json.decode(response.body);
if (jsonResponse["success"]) {
Navigator.pop(context);
}
}
I tried changing it to success == true
, but that also doesn't work. Dart doesn't properly process the response from the server