So basically when I try to log a user in and I type the password or username wrong and then I try to log in with correct credentials I get this error. And this is my code in auth.js What should I do? Is something wrong with my code? Answer !user && res.status(401).json(‘Wrong User Name’); as a statement is IMHO
Tag: backend
ExpressJS Login Validation Error: comparePassword is not a function
In the folder backend/controllers I have an authController class which handles a POST request with an email and password and then looks for a user in the database with a matching email, then when it finds the user, it tries to verify the password invoking a method called comparePassword which is defined in the user class located in backend/models. The
Could not make POST request to add comments to my backend server
I am new to express and router. When I try to add a comment to the database, the console returned the error (“Post 400 Bad request” and “Uncaught in Promise”). I’ve tried many solutions but it doesn’t work. I think it is to do with my routing. Below is my profilesRouter.js in the backend folder: Here is my profilesController.js in
“Hello World” Express does not show – I am shown my files instead
I am trying to build my first app. It’s a calculator that measures the level of caffeine in your blood. I copied the code from : https://expressjs.com/en/starter/hello-world.html (copied below), but it is not showing a page with the words “Hello World!”. Instead, I see 2 links to my 2 files within my folder “CaffeineCalc” (calculator.js + json file). I have
Efficient way to merge two array of objects in javascript based on similarities?
So I have two array of objects: and the expected result is: This is just two examples out of thousands of data, I have tried mapping through two arrays and inserting them manually however this would always result in a timeout since I think looping is quite heavy on the backend server. Is there an efficient way to do such
Reading PORT number from .env file in nestjs
I have details defined in .env file. Below is my code. host: process.env.SMTP_HOST is working properly. but when I am writing process.env.SMTP_PORT it is saying you can not assign string to number. when I wrote parseInt(process.env.SMTP_PORT) it is still not working. how to assign port from .env file Answer port: +process.env.SMTP_PORT should work casting it to a number. If there
How to log user input with Morgan?
Good morning, I am trying to log user input from user when using morgan and express. What I am specifically trying to log is noted in this image: (The user posted a request with an object that includes two key/value pairs “name” and “number”) How would I go about logging this? Custom tokens or is there a predefined method I
path broke when uploaded to server (link from js to html)
I programmed a webside and a bunch of it broke when I uploaded it onto the server (until now I only ever programmed locally and not very often at that) I fixed nearly everything but the links between pages. What works is the “a” element in html to link but most of my pages are linking to oneanother in their
Ioredis: When reconnecting redis via connect() , calling connect doesn’t reset retry times to 0
I have following options set when connecting to Redis Later on, I am exporting this client throughout project for redis queries. The issue is when Request 1 comes and there is some issue with redis, it tries to auto-connect for 4 times(+1 for initial try). Then throws error which is handled. So for now times variable(used in retrystrategy()) will have
How create a spam filter in express.js or how to filter objects based on the word in the key values?
I want create simple spam filter. I dont have an inbox yet but I was thinking when the emails are recived I could make a GET request and filter the object based on the words mentioned in the message. If the posted object is [{“id”:”1″ “email”:”xyz@gmail.com”, “cc”: “abc@gmail.com”, “message”: “You have a chance to win a lottery and be a