here's my code in backendConfig(): `recipeList: [ ...
# support-questions
f
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
hey @funk101
what is your request body?
f
I don't see req, this is the backendConfig() code
sorry, unfamiliar with the supertokens syntax
r
When u query the api, what request body do you give?
f
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
You are getting a 400 response code right?
f
yes
r
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
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
What is the response body?
f
res.body? undefined
r
No I mean on the chrome network tab
What’s the response body?
f
wait, this is res.body
body: { formFields: [Array] },
in chrome ->
{"message":"Are you sending too many / too few formFields?"}
r
Try to clean cache and rebuild project?
f
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
Are you connected to the dev env?
f
yes
r
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
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
@funk101 I’m not sure I understand your question. Could you elaborate more?
f
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
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
ok
r
Thanks. Will reply within 1-2 hours from now
f
ok
I hope it was clear
r
yes! question answered @funk101
f
cool thanks