flutter dio 重置密码 API 集成不起作用
下面是我在单击“重置密码”按钮时实现的发送电子邮件的代码。但它不能正常工作。当我输入已注册的电子邮件时,它显示“未找到用户”。它应该显示“请检查您的电子邮件以重置密码”。如何解决这个问题
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);
}
}
below is the code I implement to send email when click Reset password button. but its not working properly. when I enter already registered email it says "No User Found". it should display"Please check your email to reset password". how to solve this issue
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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么要写response.data[“message”]。它应该是 response.data["data"],因为您收到的响应参数称为 data。
Why did you write response.data["message"]. It should be response.data["data"] as the response parameter you receive is called data.