https://supertokens.com/ logo
f

funk101

05/07/2022, 1:22 PM
here's my code in backendConfig():
Copy code
recipeList: [
      EmailPasswordNode.init({
        signUpFeature: {
          formFields: [
            {
              id: "firstname",
            },
            {
              id: "lastname",
            },
          ],
        },
        override: {
          apis: (originalImplementation) => {
            return {
              ...originalImplementation,
              signUpPOST: async function (input) {
                if (originalImplementation.signUpPOST === undefined) {
                  throw Error("Shouldn't come here");
                }
                try {
                  const response = await originalImplementation.signUpPOST(
                    input
                  );
                  console.log("Response: ", response);
                  if (response.status === "OK") {
                    const formFields = input.formFields;
                    console.log("FormFields: ", formFields);
                  }
                } catch (err) {
                  console.log("Error: ", err.message);
                }

                return response;
              },
            };
          },
        },
      }),
      SessionNode.init(),
    ],
    isInServerlessEnv: true,
r

rp

05/08/2022, 4:44 AM
hey @funk101
what is your request body?
f

funk101

05/08/2022, 5:41 AM
I don't see req, this is the backendConfig() code
sorry, unfamiliar with the supertokens syntax
r

rp

05/08/2022, 5:41 AM
When u query the api, what request body do you give?
f

funk101

05/08/2022, 5:42 AM
this is the complete code
Copy code
export const backendConfig = () => {
  return {
    framework: "express",
    supertokens: {
      connectionURI:
        "https://54e49561ca4a11eca1c3c3ba0139426e-us-east-1.aws.supertokens.io:3567", //'https://try.supertokens.io',
      apiKey: "[secret key]",
    },
    appInfo,
    recipeList: [
      EmailPasswordNode.init({
        signUpFeature: {
          formFields: [
            {
              id: "firstname",
            },
            {
              id: "lastname",
            },
          ],
        },
        override: {
          apis: (originalImplementation) => {
            return {
              ...originalImplementation,
              signUpPOST: async function (input) {
                if (originalImplementation.signUpPOST === undefined) {
                  throw Error("Shouldn't come here");
                }
                try {
                  const response = await originalImplementation.signUpPOST(
                    input
                  );
                  console.log("Response: ", response);
                  if (response.status === "OK") {
                    const formFields = input.formFields;
                    console.log("FormFields: ", formFields);
                  }
                } catch (err) {
                  console.log("Error: ", err.message);
                }

                return response;
              },
            };
          },
        },
      }),
      SessionNode.init(),
    ],
    isInServerlessEnv: true,
  };
};
r

rp

05/08/2022, 5:43 AM
You are getting a 400 response code right?
f

funk101

05/08/2022, 5:43 AM
yes
r

rp

05/08/2022, 5:43 AM
So when you query the API, what is the request body in the API?
When you click on sign up button, there is an api call made. What’s the request json in that?
f

funk101

05/08/2022, 5:45 AM
req: { formFields: [ { id: 'email', value: 'jeff@jeffrenza.com' }, { id: 'password', value: 'test10101' }, { id: 'firstname', value: 'Jeffrey' }, { id: 'lastname', value: 'Renza' } ] }
and those are the extra two form fields
that req.body comes from the /api/auth[[...path]].js file
any thoughts?
r

rp

05/08/2022, 6:07 AM
What is the response body?
f

funk101

05/08/2022, 6:10 AM
res.body? undefined
r

rp

05/08/2022, 6:10 AM
No I mean on the chrome network tab
What’s the response body?
f

funk101

05/08/2022, 6:10 AM
wait, this is res.body
body: { formFields: [Array] },
in chrome ->
{"message":"Are you sending too many / too few formFields?"}
r

rp

05/08/2022, 6:13 AM
Try to clean cache and rebuild project?
f

funk101

05/08/2022, 6:20 AM
Response: { status: 'EMAIL_ALREADY_EXISTS_ERROR' } error - (api)\config\backendConfig.js (49:15) @ Object.signUpPOST ReferenceError: response is not defined
can I get rid of users in supertokens dashboard?
r

rp

05/08/2022, 6:21 AM
Are you connected to the dev env?
f

funk101

05/08/2022, 6:21 AM
yes
r

rp

05/08/2022, 6:21 AM
You can access the db directly and delete all delete the content from all the tables
Alternatively, you can make a script that loops through all users and calls the delete function on them
f

funk101

05/08/2022, 6:27 AM
alright, I'll dig into this, thanks again for your help
is there a way to put a "mask" on a phone number field during signup? I see there is a validator option. Something like "onBlur" then apply a mask to a phone number that returns the phone number format (123)456-7890 ?
r

rp

05/10/2022, 4:09 AM
@funk101 I’m not sure I understand your question. Could you elaborate more?
f

funk101

05/10/2022, 4:10 AM
I'm adding custom fields to signup form. This is my frontendConfig()
Copy code
recipeList: [
      EmailPasswordReact.init({
        signInAndUpFeature: {
          signUpForm: {
            formFields: [
              {
                id: "firstname",
                label: "First Name",
                placeholder: "Jane",
              },
              {
                id: "lastname",
                label: "Last Name",
                placeholder: "Doe",
              },
              {
                id: "phone",
                label: "Phone",
                placeholder: "(123)456-7890",
                validate: (value) => {
                  return validatePhone(value);
                },
              },
            ],
          },
        },
(partial for brevity)
I was wondering if I could do other "massaging" of data similar to the validate: option which is available here. LIke for instance, if a user types in a phone number I can change the format like "onBlur" or something, onKeydown or something
question make sense?
right now, the validate option gives you the ability to return an error message, or "undefined" if validation passes
r

rp

05/10/2022, 4:13 AM
Yea. You can! This is a good question. Could you ask this on stack overflow and send me the link? I’ll answer it there.
(With code snippet example too)
f

funk101

05/10/2022, 4:13 AM
ok
r

rp

05/10/2022, 4:27 AM
Thanks. Will reply within 1-2 hours from now
f

funk101

05/10/2022, 4:27 AM
ok
I hope it was clear
r

rp

05/10/2022, 6:26 AM
yes! question answered @funk101
f

funk101

05/10/2022, 6:26 AM
cool thanks