Home > Enterprise >  TypeError: (0 , _pages_auth__WEBPACK_IMPORTED_MODULE_3__.registerUser) is not a function
TypeError: (0 , _pages_auth__WEBPACK_IMPORTED_MODULE_3__.registerUser) is not a function

Time:07-15

My Auth.js file

const registerStudent = async (formData) => {
  const { address ,batchTime, collageName, email, fatherName, gender, guardianMobile, hscBoard, hscGPA, hscPassingYear,
    hscReg, hscRoll, imgeURL, motherName, name, paymentAmount, programName, schoolName, sscBoard, sscGPA, sscPassingYear,
    sscReg, sscRoll, studentMobile, transactionID } = formData;

  console.log(address);
  return address;
}

I am importing this function from other file like below

import { registerUser }  from '../../api/auth';

But getting warning

Cannot resolve symbol 'registerUser'

Create class 'registerUser'

After trying to execute the function I am getting the error. I am using nextjs.

CodePudding user response:

You need to export the function and rename it

export const registerUser = async (formData) => {

CodePudding user response:

You have defined your function as registerStudent and you are exporting it as registerUser, that's why it's giving you that error

import { registerUser }  from '../../api/auth';

So in Auth.js export your function like this

export const registerStudent = async (formData) => {}

and import it like this,

import { registerStudent }  from '../../api/auth';
  • Related