Supabase 重置电子邮件密码

1 reactjs supabase

我尝试在react中重置supabase的密码用户,但它说resetPasswordForEmail未定义```

 const { data, error } = await supabase.auth.api.resetPasswordForEmail(email)

    if (data) {
      console.log(data)
    }
    if (error) {
      console.log(error)
    }
  }
Run Code Online (Sandbox Code Playgroud)

我尝试运行代码,但由于我期望发送电子邮件的未定义函数,它给出了错误

Mon*_*ica 6

你可能使用的是 v2,它应该是:

supabase.auth.resetPasswordForEmail 
Run Code Online (Sandbox Code Playgroud)

不是:

supabase.auth.api.resetPasswordForEmail
Run Code Online (Sandbox Code Playgroud)

供参考:https ://supabase.com/docs/reference/javascript/auth-resetpasswordforemail

也检查一下,它有一些您可能需要了解的重要注释: https: //github.com/supabase/supabase/discussions/3360#discussioncomment-3947228