I have an API,which is written in Node.js .It is used for logging purpose.Now i'm using the same from a flutter application for performing the same Operation.
API : http://192.168.137.1:5050/User/Login
How post data to the API from flutter application
Expected Input :
{ Data: { USER_NAME: 'usenmae', PASSWORD: 'password' } }
1.From Flutter
static Future<String> loginPost(String email, String password) async {
Map<String, dynamic> jsonMap = {
'Data': {'USER_NAME': email,'PASSWORD' : password}
};
try {
final response = await http.post(
'http://192.168.137.1:5050/User/Login',
body: jsonMap,
);
return response.body;
} catch (exception) {
}
return null;
}
After calling the API by using the above code snippets i got some errors
Error : I/flutter ( 4149): send message exception called
I/flutter ( 4149): type '_InternalLinkedHashMap<String, String>' is not a subtype of type 'String' in type cast
I want pass the username and password through the api by wrapping the same with an another Data object,which look likes { Data: { USER_NAME: 'usenmae', PASSWORD: 'password' } }
Thanks