My flutter Post request is not sending the parameters to server. Whenever I check for the variables from the server I see NULL. I have tried a lot of options and I can’t seem to get it to work. Here is my code:
Future<void> listRecentCashTransactions() async{
try{
var res = await http.post(
Uri.parse(API.recentCashTransactionURL),
body: {
'userID': userID.toString(),
'sessionData': sessionData.toString(),
},
);
if(res.statusCode==200){
final resBody = jsonDecode(res.body);
final sessionDataX = resBody['checkUserID'];
int userXID = resBody['checkUserID'];
print("User ID before API call : $userID");
print("User ID after API call : $userXID");
print("Session Data before API call : $sessionDataX");
print("Session data after : $sessionDataX");
}
}
catch(e){
print(e.toString());
}
}