我正在嘗試向我的 forgotPassword 發送電子郵件,但它總是在控制臺中回傳一個錯誤,我不知道我做錯了什么。
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: FormatException: Unexpected end of input (at character 1)
這是我的代碼
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);
我嘗試列印我的 url 和 resp.body,這就是我回傳給我的。
URL - http://apiurl.com/api/Auth/[email protected]
resp.body - 無/空白
uj5u.com熱心網友回復:
User user = new User(email: user.email);
var response = await http.post(
url,
data: json.encode(user.toJson()),
);
像這樣試試。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/460128.html
