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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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? ...
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 => { ...
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 ...
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. ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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"& ...
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 ...
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 > ...
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 ...
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 ...
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 ...
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. ...
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 ...
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"; ...
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 ...
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 ...
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 ...
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 ...
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} ...
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ( ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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; ...
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: ...
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 ...
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 ...
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 + ...
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){ ...
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 ...
const accountSchema = new mongoose.Schema({ username: { type: String, required: true, unique: true }, password: { type: String, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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, ...