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
Tag: express
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
How to force Express.js to yield parameters with special characters as they are?
I am trying to complete a simple project in the freeCodeCamp “API and Microservices” curriculum. The project is rather simple, it requires working with Express.js, some routes are provided and others must be dynamically generated. In this case, either a string or number that can be parsed as new Date() object. e.g.: 1451001600000, this is a valid UNIX time in
How to use browser-side JavaScript (document, window, etc.) when running a node.js server to change the HTML document?
here’s my situation. I just started learning about node.js server with express and I find it to be an amazing technology, based on JavaScript that I am already a bit familiar with. Now, so far, whenever I want to change something on the page, I have to do it with JS on the server-side with node.js, and thus, I have
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
ReactJS cannot display image from backend folder using node.js
I’m new in React.js and I have some data (actions) coming from database. Every action has an array of images. I cannot display the images in image tag. Images are stored in a the backend folder structure like below: I was reading some questions and tried to use express.static() but it didn’t work for me: server.ts frontend I tried usgin
How to retrieve data in front end from res.send and create page for each element in DB dynamically
I’ve got a variable, say data containing data in the form of an Array with each item having a unique ID. I have sent the data from the server to the front-end on a GET request. But how do I create a seperate webpage for each element dynamically in the data array? where do i have to write the html
Propper way of Error handling in a nodejs API server
I need to handle errors in my API server on node.js. I created a error handling module, which sends the errors (only in dev mode) to the API client in a JSON object similar to this: now the problem I have is, that I need to create a new error in a submodule of my API controller when no case
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