Subabase:无法读取Signup params:json:无法将对象分解为字符串类型的Go结构字段SignupPa



我一直试图用电子邮件和密码设置超级数据库,以允许用户注册,但不知怎么的,我一直收到这个错误:

AuthApiError: Could not read Signup params: json: cannot unmarshal object into Go struct field SignupParams.email of type string

这是我迄今为止的代码

const signInWithEmail = async () => {
const { data, error } = await supabase.auth.signUp({
email: { email },
password: { password },
options: {
data: {
first_name: "John",
age: 27,
},
},
});
error ? console.log(error) : console.log(data);
};

对于表格,我有这样的代码:

<form onSubmit={(e) => e.preventDefault()}>
<div className="grid gap-2">
<div className="grid gap-1">
<label className="sr-only" htmlFor="email">
Email
</label>
<input
id="email"
placeholder="name@example.com"
className=""
type="email"
autoCapitalize="none"
autoComplete="email"
autoCorrect="off"
name="email"
value={email}
disabled={isLoading}
onChange={(e) => setEmail(e.target.value)}
/>
<input
type="password"
placeholder="Enter a pasword..."
className=""
value={password}
autoComplete="off"
onChange={(e) => setPassword(e.target.value)}
/>
</div>
<button
onClick={(e) => {
e.preventDefault();
signInWithEmail();
}}
disabled={loading}
className=""
>
{isLoading && (
<Icons.spinner className="mr-2 h-4 w-4 animate-spin" />
)}
Sign In with Email
</button>
</div>
</form>

我如何解决上面的错误,我遵循了文档并使用了他们提供的代码,但我似乎可以克服这个错误。

当电子邮件和密码不需要时,它们会被封装在{}中。

您当前的代码

email: { email },
password: { password }

应该如何

email: email,
password: password

相关内容

最新更新