I am trying send an email to my forgotPassword but it always returns me an error in console, I don't know what I'm doing wrong.
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: FormatException: Unexpected end of input (at character 1)
Here's my code
final String _url = 'apiurl.com';
Future<String?> forgotPassword(String email) async {
final Map<String, dynamic> authData = {
'email': email,
};
final url = Uri.http(_url, '/api/Auth/ForgotPassword', authData);
final resp = await http.post(
url,
body: jsonEncode(authData),
);
print(url);
print(resp.body);
I tried print my url and resp.body and this is what ir returned me.
URL- http://apiurl.com/api/Auth/[email protected]
resp.body- Nothing/Blank
CodePudding user response:
User user = new User(email: user.email);
var response = await http.post(
url,
data: json.encode(user.toJson()),
);
Try like this.