I am calling a remote PHP file to get some data into my Flutter app.
This is the Flutter function:
Future<void> registrarUsuario() async {
var url = Constantes.adminUsuariosUrl 'nuevo_usuario.php';
final response = await http.post(Uri.parse(url), body: {
"email": controllerEmail.text,
"password": controllerPass.text
});
print("response ${response.body}");
}
Calling the function the print output is empty.
flutter: response
But calling the PHP file using Postman gives me the following output:
[{"id":"57","correo":"[email protected]"}]
I would like to update the funtion registrarUsuario to get the json objects from the response.body
CodePudding user response:
Encode the body content in request
Future<void> registrarUsuario() async {
var url = Constantes.adminUsuariosUrl 'nuevo_usuario.php';
final response = await http.post(Uri.parse(url), body:json.encode({
"email": controllerEmail.text,
"password": controllerPass.text
}));
print("response ${response.body}");
}