Questions tagged [express]

Express.js is an innovative and versatile framework for developing web applications on Node.js, offering a comprehensive range of powerful features that enable seamless creation of robust web solutions.

How does the router.get('/') function in Express handle requests in the routes directory that are not '/'?

My code structure is set up as follows: const routes = './routes/' const usersRouter = require(routes +'users'); /*more code*/ app.use('/users', usersRouter); Within the users.js file, I have set up the following: const express = require('express'); con ...

Cookies are not persisting in the browser even after successful login on a React Node.js application deployed on Render hosting platform

I recently completed a Full-stack MERN (React + Node.js + MongoDB) project by following a tutorial on YouTube. You can check out the tutorial here. The official GitHub repository for this project can be found at https://github.com/codinginflow/MERN-course ...

Sorry, but I am unable to complete this task as it involves rewriting content that has been provided by you. How about

Attempting to retrieve the date from a Unix timestamp with a timezone using moment-timzone var moment = require('moment-timezone'); let date = moment.tz('Asia/Kolkata').unix(dateInUTC).format('YYYY-M-DD-H-mm-s') Encoun ...

Troubleshooting the issue of undefined Req.body in POST requests in Node.js using Express 4.x

Using a middleware called body-parser, I encoded the form values to access them in the req.body object. However, when debugging my code, I noticed that req.body is undefined. Here is the snippet of my code: var express = require('express'); var ...

Whenever using Express JS, an error message that is commonly encountered is: "TypeError: Assignment to constant

I have been working on creating an API with Express JS. The API was running smoothly until I added authorization for some routes using the JsonWebToken package. When I tried to use the token generated by the package, I encountered the following error: Type ...

What steps should be taken to resolve the update problem in Sequelize?

Having an issue with the update method in MySQL ORM. User.update({ ResetPasswordToken : resetPasswordToken },{ where: { UserName: 'testuser' } }) Receive this Sequelize Log: Running query: UPDATE Users SET ResetPasswordToken=?,updatedAt=? WHE ...

Guide on sending data to MongoDB using Postman

I am currently facing an issue while trying to send data to the MongoDB database using Postman. Despite everything seeming fine, I keep encountering errors. https://i.stack.imgur.com/Gcf5Q.jpg https://i.stack.imgur.com/ntjwu.jpg https://i.stack.imgur.co ...

The function 'get_categories' cannot be accessed due to its undefined state

I've been working on integrating a node module from Semantics3 into my project. The code I've written is stored in a file called search.js within the routes folder. However, I'm encountering an issue where I am getting an undefined-method er ...

What is the process for sending a multipart/form-data form with an uploaded file to a separate server using Node.js (specifically Express.js)?

When sending a form with file using enctype="multipart/form-data" to node.js (using the express.js framework), how can I easily resend this post request to a different server without changing its contents? ...

Utilizing Sequelize validation through condition objects

const db = require("../models"); const Meet = db.meet; checkDuplicateTime = (req, res, next) => { Meet.findAll({ where: { tanggal: req.body.date, waktu: req.body.time } }).then(time => { ...

Troubles with rendering output of compiled program when run within a Dockerized environment

My website features a file upload and submit button. When a user uploads a C++ file and submits it, a Docker container is started to compile and run the code. The objective is to showcase the program's output on the web server. Initially, I experienced iss ...

Updating the code for Express to store JSON data in a database field

Struggling with setting up my first basic CRUD functionality in Express JS and I can't seem to track down this frustrating bug. Every time I attempt to update a field, instead of displaying the new data, the JSON from that field is shown on the view. ...

Express get requests are failing to handle query strings

Whenever I try to extract the year and month from the URL like this: http://localhost:3000/api/posts/2018/4, the code doesn't seem to work properly. Instead, it returns an error saying: Cannot GET /api/posts/2018/4 Here's the JavaScript code I&a ...

The error being caused by JavaScript's asynchronous property

Encountering a challenge while setting up the registration page for my application. The setup involves a react front end and a node/express back end. The tasks to be performed in react are: Initiate a backend call to node to validate user existence If use ...

Using NestJS to populate data will only populate the first element

I have a Mongoose schema in NestJS structured like this: ... @Prop() casinoAmount: number; @Prop() gameHyperLink: string; @Prop() casinoHyperLink: string; @Prop({ type: Types.ObjectId, ref: 'Game' }) games: Game[]; } I'm trying to create ...

What is the best way to automatically launch my MERN application upon startup?

My friends and I recently launched a small startup and I developed a customized todo app for our team. I wanted to avoid the costs and challenges of uploading the application online, so I came up with an idea. What if I could replicate the project on all ...

How to fetch React route parameters on the server-side aspect

I encountered a challenge while working with ReactJS and ExpressJS. The user uploads some information on the /info route using React and axios. Then, the user receives route parameters from the server side to redirect to: axios.post('/info', Som ...

Enhancing collaboration: Seamlessly sharing interface/interface/model files in the integration of

Currently, I am engrossed in developing an application with an Express backend and Typescript whilst utilizing Angular for the frontend. The only snag I'm facing is that I require interface/models files from the backend to be accessible on the frontend as ...

Each time a post request is made, SessionID creates a distinct value

I'm facing a challenge in identifying the user on my application using sessionId instead of actual user account information. However, I've observed that the sessionId changes every time the user interacts with the page, as seen below. My objectiv ...

node index of data that has been posted

My HTML file is quite straightforward: <form method="post" action="http://localhost:3000/post"> <input name="name" type="text"/><br /> <input name="last_name" type="text"/><br /> <button id="submit" type="submit"& ...

Steps for removing an element from an array using Mongoose and Node.js

After reading and attempting to implement the solutions provided by others, I am still struggling to understand why it's not working for me. This is my first project involving backend development. While progressing through a course, I decided to work on so ...

"Although the Set-cookie is present in the response header, it is not being properly

I developed a GraphQL server using apollo-server-express, and it is currently running on localhost:4000. Upon sending a query from GraphQL playground, the response includes a set-cookie in the header: response header However, when checking the storage > ...

Trouble arises when attempting to remove an object using a combination of Node.JS, Mongoose, MongoDB, and

In my setup, I have two collections: one is called subcategories and the other is called categories. The categories collection includes a field known as subcategories which is an array containing the ids of the subcategories from the subcategories collecti ...

Execute a JavaScript function on a Node server following a click event in an HTML document

Hello everyone, I am currently working on a project using node.js in a Windows environment. With the help of the express module, I am trying to create a static page that includes a Submit form. When someone clicks the "Submit" button, I intend to execute a ...

Issue with Typescript and react-create-app integration using Express

I'm relatively new to Typescript and I decided to kickstart a project using create-react-app. However, I encountered an issue while trying to connect my project to a server using express. After creating a folder named src/server/server.ts, React automatic ...

The error thrown by Mongoose, stating "TypeError: Cannot read property 'catch' of undefined," is not caught after the data is saved

After updating to Mongoose version 5.0.15, I encountered an error that says TypeError: Cannot read property 'catch' of undefined when trying to save my object with errors found, even though everything was working fine on Mongoose version 4.13.11. ...

Utilizing Ephemeral and MaxAge parameters in express-session for enhanced session management

I'm working on implementing the session management for an express-js application using the express-session package. Here are the specific requirements I need to meet: The cookie should be destroyed when the browser is closed. The cookie should expi ...

Unable to retrieve the image

When trying to fetch an image, I encountered the following error: Failed to load resource: the server responded with a status of 404 (Not Found) TopBar.jsx import { useContext } from "react"; import { Link } from "react-router-dom"; ...

Guide to Making GraphQL API Calls from a Node.js/Express Server

After successfully implementing a schema and resolvers for my Express server, I tested them through /graphql. Now, I am looking to utilize the queries from a REST API by calling them in GET handlers like this: //[...] //schema and root are properly implem ...

The most efficient method for searching and deleting elements from an array in Mongoose

I'm currently struggling with my implementation of mongoose in express. It seems like I'm using too many queries just to add something to a document, and I can't help but feel that there's a simpler way to achieve this. This function i ...

Trouble arises when attempting to showcase document fields in MongoDB

As a beginner in programming, I am putting in my best effort to figure things out on my own. However, I seem to be stuck without any guidance. I am attempting to display all products from the mongoDB based on their brand. While I have successfully set up a ...

Understanding the process of parsing an array in form-data in Node.js

https://i.stack.imgur.com/FPhX1.png I'm currently facing an issue while trying to read the image above in Node.js. I am using Express.js and have attempted to debug req.body, but it is returning an empty object {}. Even though I am using app.use(bodyPars ...

Tips for managing data received from an Axios post request

I have a setup with a react frontend and node.js backend. Currently, I am successfully sending a POST request using axios: const [logins, setLogins] = useState({}); function updateLogins(e) { setLogins({...logins, [e.target.name]:e.target.value} ...

The issue of the Angular controller not functioning properly in conjunction with Node Express

After creating an angular app (version 1.5.7), I wanted to deploy it to heroku. To do this, I implemented Node and used express to serve the main index.html file for heroku to build since it doesn't support plain angular apps. However, after making th ...

``After successful implementation of app.get in a Node Express application on Mac OS, encountering

app.get("/test", function(req, res, next) { res.sendFile(__dirname + '/test.html'); }); Seems simple enough, right? When I run this server on my Mac, everything works fine. However, when I try to run it on a PC, my browser shows a "cannot GET" error. I ...

Sending form data from a React application to a backend Express server

I have a React form that captures candidate information and sends it to an Express server. I am using axios to make a POST request to the backend, where I want to log the candidate object. The form is functioning correctly in accepting input. import React, ...

Error occurred while looking for user by ID in the everyauth

I previously had a working example with express 2.*, but now I am transitioning to version 3.*. The issue arises during authentication with Facebook, causing some problems. Everything works fine until everyauth makes the GET request to Facebook and then re ...

Strategies for accurately mapping values from prisma to TypeScript types?

I'm in the process of developing an ecommerce webshop, utilizing express for my backend and the Prisma ORM. While the system is functional, I believe there is room for optimization, particularly in how I handle types and utilize Prisma as this is my first ...

Error encountered in Angular CLI: Attempting to access property 'value' of an undefined variable

I am encountering an issue while trying to retrieve the values of radio buttons and store them in a MySql database. The error message I receive is TypeError: Cannot read property 'value' of undefined. This project involves the use of Angular and ...

Utilizing Promises with Multiple .then() in JavaScript

I'm currently in the process of creating an array structure. In this structure, we have different parts and each part contains articles. What I've done is create a promise to gather all the parts using .then(), then I need to iterate through eac ...

Angular Universal involves making two HTTP calls

When using Angular Universal, I noticed that Http calls are being made twice on the initial load. I attempted to use transferState and implemented a caching mechanism in my project, but unfortunately, it did not resolve the issue. if (isPlatf ...

Important announcement using Connect-flash and Jade

I am in the process of creating a website that requires login authentication using node.js, express, and Passport. On the signup page, I am looking to implement a feature where a message is displayed if a username is already taken. Currently, the code is f ...

Heroku, Express, React, and NodeJS - struggling with HTTPS inconsistency issue

I'm facing an issue with my express routes not working properly when deployed on Heroku. The odd thing is that the routes work fine when accessed via HTTP, but not via HTTPS. Interestingly, they do work on HTTPS with Internet Explorer and Microsoft Edge, b ...

I'm having trouble adding headers to my axios post request. The post route functions correctly in Postman but does not work when using axios. Can anyone

Implementing JWT for protecting a post route in my nodejs, express, react application has been quite a challenge. While testing with postman and adding the JWT token to the headers works flawlessly to add users to the database, I encounter a 401 response ( ...

Hiccup: encountering ENOTFOUND in nodejs when making a get request

Running a web server on node, here is the code: var restify = require('restify'); var server = restify.createServer(); var quotes = [ { author : 'Audrey Hepburn', text : "Nothing is impossible, the word itself says 'I'm p ...

Displaying Markdown-formatted blog entries using Node.js and Express

Hi there, I've been diving into Node.js with Express for the past week and I'm really enjoying it. So far, I've grasped the fundamentals of building an MVC framework on top of it, and using JavaScript has proven to be a much cleaner experience compared to ...

An API request was successfully completed with security measures in place; if not

I am facing a challenge with managing two tables, one for users and the other for user roles. The user role table is used to store multiple roles for each user. I have created two APIs to handle deleting a user - one API deletes the user based on their use ...

Find a solution for simultaneously saving data to multiple instances of MongoDB

Recently, I ventured into creating a booking website where users can choose a date for their reservation. Upon sending a request to /api/v1/reserve, the system would validate the data, generate a payment intent using Stripe, store the reservation in the da ...

What steps do I need to take to integrate the Firebase Admin SDK into my Angular project?

Is there a way to integrate Firebase Admin SDK into my Angular application? Currently, I am using Firebase Authentication services in my application and everything I need for user registration and authentication is handled by Angularfire2. I've read ...

Receiving two HTTP requests when only one was originally sent

Currently, I am immersed in a practice project that involves working with Express, Mongo, and Mongoose. My main task is to establish a fundamental CRUD structure before adding more intricate features. In my application, the http://localhost:3000/campgroun ...

Error: Unable to simplify version range

Attempting to follow the Express beginner's guide. I created an app and executed npm install as per the provided instructions. > npx express-generator --view=pug myapp > npm install npm ERR! semver.simplifyRange is not a function npm ERR! A complete ...

Prevent duplication in HTTP POST requests using Express and Node.js

How can I prevent a duplicate object from being created during a post request if the object already exists? I have included my code and JSON object below. I attempted to use next(), but it did not work as expected, resulting in a new object with a differen ...

Errors from Mongoose do not get propagated from the router to the app layer

There is a single API application set up like so: const express = require('express') const app = express() const router = require('express').Router() ... route.post('/dogs', (req, res, next) => { const dog = new Dog() // defined in the actual applica ...

What could be causing nodejs to still return a 404 error even after successfully handling the request for the specified

Utilizing jwtwebtoken, express, mongo, nodejs, and bcrypt for the backend APIs. I have observed that the router for the localhost:3000/account/update path is being executed, but it throws a 404 error after a successful operation. The database connection is ...

Sometimes, Express may return the message "not found" on and off

After working with express for many years, I find myself a bit out of practice with TypeScript - and it seems like my eyesight is failing me! This is the first time I've encountered this issue, so I must be missing something... My current dilemma is as fo ...

Receiving no communication from Express Router

Having trouble receiving a response from the server after making get/post requests. I've tried adjusting the order of functions in index.js without success. I also attempted to send a post request using Postman to localhost:8080/register, but the requ ...

Express router takes on a distinct path when including a parameter

I currently have two different routes set up. When attempting to access the /name route and pass a name param, it successfully reaches the /name endpoint without any parameters. However, as soon as I modify it to '/name/:name' in order to retrie ...

NodeMailer is throwing an error stating "is not a constructor" along with an unhandled promise rejection

Currently, I am working on a project where I have my main index.js file and I am calling the Nodemailer module using the following code: new aaaaa.send(`${userEmail}`) Below is the content of my nodemailer.js file: const nodemailer = require('nodem ...

Can you explain the definition of "mount" in the context of Express?

Currently diving into the world of Express.js, I stumbled upon this definition: "An Express router offers a limited set of Express methods. To initialize one, we call the .Router() method on the main Express import. To utilize a router, we mount it a ...

Having trouble with my nodejs backend when trying to choose collections

In my primary app.js file, I establish the mongodb connection to my mlab database. const mongo = require('mongodb').MongoClient; const express = require('express'); const path = require('path'); const bodyParser = require(&ap ...

Unable to transmit an object using ExpressJS

Greetings. I am currently trying to comprehend ExpressJS. My goal is to send a simple object from the express server, but it only displays "cannot get" on the screen. app.get("/", (req, res, next) => { console.log("middleware"); const error = true; ...

Using Express.js to leverage Vega for generating backend plots

Exploring ways to create plots using backend code and transfer them to the front end for display. Could it be feasible to generate plots on the server-side and then transmit them to the front end? I am interested in implementing something similar to this: ...

Sharing data between ejs and javascript files

When using Express, I have encountered an issue with passing a variable to an EJS file called "index.ejs". res.render("index",{passedUser:req.user.alias}) Although I am able to successfully print it using <%=passedUser%> in the EJS file, I require ...

Using multer for file upload causes React application to refresh

Important Update: The issue I am facing is related to hot-reloading in Creact React App. For more information, check out the following links: https://github.com/expressjs/multer/issues/566 https://github.com/facebook/create-react-app/issues/4095 I am del ...

Several directories for viewing in Node.js with Express

I have been researching different solutions, but I am still unsure about how to effectively integrate Express with multiple view folders. Imagine an Express application divided into distinct parts, each organized in its own subfolder: app +partA + ...

Ensuring Node.js backend JavaScript waits for completion of my bash script before proceeding

Running three bash commands through a Node.js code snippet. Here's a portion of the script: exec(str, function(error, stdout, stderr){ console.log('stdout:'+stdout); console.log('stderr:'+stderr); if(error!=null){ ...

Timeout when making an HTTP request

One question I have is regarding socket timeout in NodeJs. To address the issue, initially, I included the following code : req.socket.once('timeout', function(err) { imports.logger.warn('Express socket timeout.', err); res.status(504 ...

Error: The schema configuration is incorrect: `U` is an invalid type specified at path `0`

const accountSchema = new mongoose.Schema({ username: { type: String, required: true, unique: true }, password: { type: String, ...

Quick tutorial on extracting an array of objects in Node.js

I need assistance with creating a simple todo app using React JS and Node. How can I fetch an object array (task list) from Node to React in order to display that list when a button is clicked? const lists =[ {toDo: "learn react"} ] app.post(&apos ...

Refreshing user details: using Express with Node.js

I have been struggling with this task for hours without any success. My goal is simple - I just want to update user data, but it seems like there's something I'm not grasping in my app.post(..) function. Despite feeling confident that I was handling the pr ...

Capture (and perhaps reject) incoming web socket upgrade requests

I am facing a challenge with my Node.js server as I send a web socket upgrade request. The Authorization header in the request contains login information that needs to be validated against a database entry before allowing the connection. To prevent potenti ...

Refresh the screen after 10 seconds

Apologies if I'm not explaining this well in advance. I am looking to create a dynamic webpage using JavaScript that automatically updates every 10 seconds. Does anyone have an example code snippet for this? **Specifically, allow ...

Is there a reason why Express is defaulting to error handling with a 404 response for all routes, including ones

I have created a fresh Express app using the express generator. In order to handle errors, I included a console.log in the error handler: // error handler app.use(function(err, req, res, next) { // set locals, only providing error in developm ...

Guide on developing an npm package which allows for seamless importing and integration with current functionalities

I am just starting out with creating node npm packages. Currently, I am attempting to develop a package that can wrap around an existing express route and then import the route into my npm package's main js file for further manipulation. Here is an examp ...

Getting the ID of an element in ReactJS following a POST request

I am looking to implement a function that creates an entry in a database using data collected from a basic form. Once the user clicks on submit, this function is triggered: createItem(item){ this.state.bucket_list.push({ name: item, ...