flutter dio 重置密码 API 集成不工作

flutter dio reset password API integrating not working

下面是我在点击重置密码按钮时发送电子邮件的代码。但它不能正常工作。当我输入已经注册的电子邮件时,它说“找不到用户”。它应该显示“请检查您的电子邮件以重置密码”。如何解决这个问题

postman request

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);
    }
  }

为什么要写 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);
  }