I have been trying to setup supabase with email and password to allow users to sign up but somehow I keep getting this error:
AuthApiError: Could not read Signup params: json: cannot unmarshal object into Go struct field SignupParams.email of type string
This is my code so far
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);
};
for the form I have this code:
<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="[email protected]"
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>
How can I resolve the error above, I have followed the docs and used the code provided from their but I can seem to overcome this error.
CodePudding user response:
You have email and password wrapped in {} when they don't need to be.
Your current code
email: { email },
password: { password }
How it should be
email: email,
password: password