Skip to content
Advertisement

Tag: express

How does the const a = express() works exactly?

I recently started learning Node/express. One doubt is bugging me for a couple of weeks now. I know what this does, and I’ve been able to get past it. But I cannot wrap my head around the logic used in the line const a = express(). I don’t think I have seen this before in javascript. In this case, express

Cannot GET routes other than “/” express

I’m trying to create a web app with the MVC pattern and express in node.js. This is my project structure: project structure image app.js: loginController.js: The problem is that I can access the index page (“/”) but not the login page (“/login”) even when the code for both is almost identical. Here’s the code of indexController.js: I don’t really know

Uploading an image to an API with multer

I’m trying to make an application that requires image uploading and storing, I’m using Express, Mongoose and Multer and trying to upload to MongoDB. Currently when I try to upload an image, Multer does create a folder and store the image in that folder, but it doesn’t save the item to the database and it crashes the server giving the

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

How to Configure Server API to Receive a Request Body Using Fetch and Express JS?

I’m trying to send a JSON file from the client to the server, but when I try to do so I get the error: “No ‘Access-Control-Allow-Origin’ header is present on the requested resource”. I also get the errors “POST http://localhost:3000/ net::ERR_FAILED” and “Uncaught (in promise) TypeError: Failed to fetch at index.js:6:1”, but I’m not sure if they’re relevant or symptomatic

Request interceptors not modifying the value of request header in node js

I am using http-proxy-middleware to create a proxy and it’s running successfully. Before calling app.use(‘/’,proxy_options); I am trying to intercept my request and modifying the request header but updated value is not reflecting in headers. Even I tried with req.header.authorization=token; and also without next();. When I am trying to print the my request header authorization:” is coming as blank. Can

Advertisement