Reputation: 719
I'm using the exact code example of Flutter's HTTP package with just different body contents, as in:
res = await http.post(
Uri.parse("http://localhost:3000/login"),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, String>{
'email': "[email protected]",
"password": "testPassword",
}),
);
Yet I'm getting the error type 'String' is not a subtype of type 'Map<String, dynamic>'
for the body format. And I can't leave the body without encoding to be a Map<String, String>
because this will fail the API.
What should I do?
Upvotes: 0
Views: 67