Skip to content
Advertisement

Tag: express

Node JS + Mongo DB: ValidationError: User validation failed: username: Path `username` is required because it force replaces the field

I am trying to save my data to a mongodb server but somehow it force replaces the first variable as id so it is throwing the above mentioned error. in router code I am doing console.log(req.body,cred) and here is the result I get: { emailAddress: ‘test@gmail.com’, password: ‘123456’, id: ‘6070cbd7c603550ac4385485’ } { _id: 6078c61277453c2170d7e177, password: ‘123456’, id: ‘6070cbd7c603550ac4385485’ } Can

users is not defined in nodejs at bcrypt.compare

I am doing the following thing in node js 1.register and save user in mongodb 2.generate token when registered. 3.authorization using token 4.login user and this is my router file but when i give post request . It says users is not defined at pls find an solution for this . I am sorry if it is a silly or

express post request body shows up as empty

server code client code terminal shows: {} tried pretty much everything so help would be very much appreciated thanks in advance:) Answer You said mode: ‘no-cors’ which tells fetch to silently ignore anything which requires CORS permission. Setting the Content-Type to application/json requires CORS permission so your request is sent with Content-Type: text/plain instead. This doesn’t trigger the JSON body

Error: Cannot GET using Express & handlebars

I’m new to JS/Handlebars and I’m unable to display an image from my home.hbs file in VS Code. When I run the server, I get this: Here’s my server code: My “home.hbs” code: The “GET” error specifically states Cannot GET /public/img/logo.png That’s all the info I have, any help would be much appreciated. Answer Specify the path prefix for the

chaining operator throwing error in express app

I am trying to use the optional chaining operator (?.) in my express app – it throws error whenever i try. I have tried all variations Answer You have 2 options Upgrade your Node version. Only these versions support optional chaining. As you can see, only Node 14.5+ supports optional chaining If you want to support older versions such as

Advertisement