https://supertokens.com/ logo
form field issue
m

miguelstevensbe

04/19/2023, 10:43 AM
I'm getting an error saying ""Are you sending too many / too few formFields?" I'm following the example from the docs, this is my frontend and backend code, am I missing something? ( I checked, the values are populated with data when sending the request to ST) frontend code
const response = await EmailPassword.signUp({
        formFields: [
            {
                id: "invite",
                value: invite.value.id
            },
            {
                id: "password",
                value: password,
            },
            {
                id: 'first_name',
                value: firstname
            },
            {
                id: 'last_name',
                value: lastname
            },
        ]
    });
And the backend
EmailPassword.init({
                signUpFeature: {
                    formFields: [
                        {id: "invite"},
                        {id: "password"},
                        {id: "first_name"},
                        {id: "last_name"},
                    ]
                },
                override: {
                    apis: (originalImplementation) => {
                        return {
                            ...originalImplementation,
                            signUpPOST: async function (input) {
                                if (originalImplementation.signUpPOST === undefined) {
                                    throw Error("Should never come here");
                                }

                                let response = await originalImplementation.signUpPOST(input);
                                console.log(input)


                                return response
                            }
                        }
                    }
                }
            }),
r

rp

04/19/2023, 11:19 AM
hey @miguelstevensbe email is a necessary form field
m

miguelstevensbe

04/19/2023, 11:22 AM
Aah hmh, can I disable that? I'm using the invite field so that I can get the email in the backend, so the user can't tamper with it.
The invite code is sent back to the backend, and then we get the email, role etc from the invite code. It's a good system for letting a user signup on invite
r

rp

04/19/2023, 11:24 AM
i see. You can just add some fixed, random email to it like
example@example.com
and just ignore that form field in your override.
m

miguelstevensbe

04/19/2023, 11:25 AM
Right, okay! Thanks for the help RP