下面是我在單擊重置密碼按鈕時實作發送電子郵件的代碼。但它不能正常作業。當我輸入已注冊的電子郵件時,它顯示“未找到用戶”。它應該顯示“請檢查您的電子郵件以重置密碼”。如何解決這個問題
郵遞員請求
class _LoginFormState extends State<SignUpForm> {
final _formKey = GlobalKey<FormState>();
//String _userName = "";
String email = "";
Future Resetpassword() async{
try {
var response = await Dio().post('https://app2-hi.herokuapp.com//user/forgotpassword',data:
{
"email": email,
}
);
if(response.data["message"] == " Please check your email to reset password."){
Get.snackbar("success","Email Sent Sucessfully!");
}else{
Get.snackbar("error", "No User Found");
}
print("res: $response");
} catch (e) {
Get.snackbar("error", "No User Found");
print(e);
}
}
uj5u.com熱心網友回復:
為什么要寫 response.data["message"]。它應該是response.data["data"]因為您收到的回應引數稱為data。
if (response.data["data"] == "Please check your email to reset password.") {
Get.snackbar("success","Email Sent Sucessfully!");
} else {
Get.snackbar("error", "Email Not Sent. Please try again.");
}
print("res: ${response.data}");
} catch (e) {
Get.snackbar("error", e.toString());
print(e);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/435925.html
