skip to Main Content

I’m using Sequelize to build a user registration feature in my Node.js application. When I try to check for an existing user using the email parameter, I’m encountering the following error: "WHERE parameter ’email’ has invalid ‘undefined’ value."
enter image description here
in db it is DataTypes.STRING

I’ve checked the request body to ensure that the ’email’ field is being sent.
I’ve verified that my server is set up with the express.json() middleware for parsing JSON.
I expect the code to correctly query the database for an existing user based on the provided email address and handle the case where the user already exists.

2

Answers


  1. I’ve checked your code I’m wondering that you register middleware express urlencoded
    Please check your main express code maybe you forget to add it

    app.use(express.urlencoded({ extended: false }));
    
    Login or Signup to reply.
  2. i’m not intersted with Sequelize so maybe my answer is wrong but anyway
    the first thing i’m intersted in your code is **async**(req,res)=>{} so you have a reason to use async and await for your controller right???
    yeah you have and what’s the reason? so in Sequelize when you want to use findOne() you need to use await for that but you didn’t use it so it’s doesnt return anything!

    i’m get this problem so much at mongoDB so don’t worry!
    so you need to do this:

    const find = await findOne(where:{email})
    
    if(find)
    //do code
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search