Future<User> authUser(String username, String password) async (
Map data = {
'username' : username,
'password' : password,
};
var authUserResp = await http.post (
new Uri.http('localhost:8000','apiquery'),
headers: {
'Content-type' : 'application/json',
'Accept' : 'application/json',
},
body: json.encode(data),
);
print(authUserResp.statusCode);
return User.fromJson(jsonDecode(authUserResp.body)['data']);
)
The status code on successful post operation in Postman is 201 for created. But in flutter the status code being returned is 200. And on the local api server the body of request is an empty map as {}.
question from:
https://stackoverflow.com/questions/66059133/http-post-request-to-server-doesnt-send-the-body-with-it-in-flutter-on-the-ser 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…