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
Tag: backend
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
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 to apply a mask to an item coming from an API with Javascript
I have a basic CRUD situation, where in the form, when I send the data, it inserts the mask normally, and when sending it to my local API, I format it and leave it in numeric format. But how am I …
Mongoose Return Error Code 11000 duplicate index
i am using mongoose as database for my project, now i am struggling with add data to multiple collections and this is my route router.post(‘/’,add_new_user_to_specific_collection,…
MongoDB find by _id
I’m building a Node.JS app, and i have a function that returns all the records if none of the queries were sent and, if sent, it returns all the records satisfying my query. Here’s my code: const …
How can i get input data from a form in node.js?
Working on a weather application in node.js But when i tried to get the input value through document.getElementById to show weather about a specific location it is showing error i have a file in my …
HttpOnly Cookies not found in Web Inspector
I am working on user authentication for a website built using the MERN stack and I have decided to use JWT tokens stored as HttpOnly cookies. The cookie was sent in a “Set-Cookie” field in response header when I used Postman to make the request but not in the Safari Web Inspector as shown in the image below. There are
POST http://localhost:3000/data 400 (Bad Request) when trying to send data from client to server
Hey guys so i’ve got some problem with sending data from client-side to server-side. Basically i have a function that on click is setting variable called categorySearch to a string e.g categorySearch =…
How To Get The URL After Redirecting from Current Page To Another Using Puppeteer?
I’m Aadarshvelu! Recently Started Testing My WebApp Code Using Jest With Puppeteer. So I Have Page Which All Credentials Have Been Filled With Puppeteer.But When SummitButton(‘signBtn’) Clicked POST process Starts Is There Any Test That Process POST Request?.. Or How Do I Know Test Has Been Completely Finished? Or How to Get The Redirect Page URL While Test Running? This