#Module parse failed: Argument name clash (97:42)

5 messages ยท Page 1 of 1 (latest)

snow viper
#

Using server actions i get this error:

<form
            action={async (formData) => {
              "use server";
              console.log(`๐Ÿš€ ~ action={ ~ formData:`, formData);
              console.log(`๐Ÿš€ ~ action={ ~ formData:`, session);
              // if (!session?.user?.id) await setRole(session?.user?.id, formData.get("rolle") as any);
              const id = session?.user?.id;
              console.log(`๐Ÿš€ ~ action={ ~ id:`, id);
            }}>
#

session is from getServerSession

delicate fox
#

`
import { useState } from "react";
import { useSession } from "next-auth/client";

function MyForm() {
const [session] = useSession();
const [formData, setFormData] = useState({});

const handleSubmit = async (event) => {
event.preventDefault();

console.log("Form submitted", formData);
console.log("Session", session);

const id = session?.user?.id;
console.log("User ID", id);

// Perform any necessary actions with the form data
// and user ID here

// Example: Call your setRole function
// if (!session?.user?.id) await setRole(session?.user?.id, formData.get("rolle") as any);

};

const handleChange = (event) => {
setFormData({ ...formData, [event.target.name]: event.target.value });
};

return (
<form onSubmit={handleSubmit}>
<input type="text" name="name" onChange={handleChange} />
<input type="email" name="email" onChange={handleChange} />
<button type="submit">Submit</button>
</form>
);
}

export default MyForm;
`

#

Make sure to update the form inputs with your actual form fields and adjust the form logic as needed for your specific use case.

snow viper
#

thanks for your answer