948 viewsMern Amazona
0 Comments

Good day,Basir:
Appriciate for your sharring in Youtube, and I have a question to asked.
In the lesson 25 of Amazona, I tried to ‘sign up’ a new account, the web-brower show me “User validation failed: isAdmin: Path `isAdmin` is required.” It is caused by ‘isAdmin: { …, required: true}’ which in userModal.js as I knew.
My question is when I singin to the weibsite, it would res.send ({…,isAdmin: user.isAdmin,…}) and signup will send ,too.
Why the error msg response on signup only? When I modify require to “false”, it sign-up successfully.
Could you clean this confussion to me ?

Best Regards

Bassir Answered question October 13, 2022

hello there,

isAdmin is a required field but if you don’t set it the default value will be set to false:

https://github.com/basir/mern-amazona/blob/master/backend/models/userModel.js#L8

you should not get “Path `isAdmin` is required” if default: false is there.

Bassir Answered question October 13, 2022
You are viewing 1 out of 1 answers, click here to view all answers.