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.

Error message: NodeJS express unknown function or method get()

Currently, I am facing an issue while working with express and Pug (Jade) to render a page as the get() function is returning as undefined along with warnings... I followed these steps: npm install express --save npm install pug --save Here's a sn ...

Utilizing Nunjucks: Implementing relative file paths within HTML documents

When utilizing Flask and Jinja2, I am able to achieve the following: <link href="{{ url_for('static', filename='css/bootstrap.css') }}" rel="stylesheet" type="text/css"/> <script src="{{ url_for('static', filename=&a ...

Get Notified of Errors Instead: Utilizing SweetAlert2 for Error Alerts Only

I am in need of help with implementing a functionality in my code that switches between successful operation alerts and error alerts with sweetalert2. Currently, only the error alerts are being displayed. I'm not sure where I'm going wrong. Here ...

What is the best way to manage the parameter in a route?

I set up a few routes : var express = require('express'); var router = express.Router(); router.post('/isAccessible/:orgaId', function(req, res, next) { res.send("------ param = "+orgaId); }); module.exports = router; Next, in an ejs file : <sc ...

Utilizing MongoDB to create time-based event triggers

I am working on a front-end application using Angular and a back-end system powered by Express.js. My goal is to have notifications displayed on the front end based on meetings scheduled at specific times. For example: If there is a meeting scheduled f ...

My server keeps crashing due to an Express.js API call

I'm completely new to express.js and API calls, and I'm stuck trying to figure out why my server keeps crashing. It works fine the first time, rendering the page successfully, but then crashes with the error: TypeError: Cannot read property &apo ...

What is causing the issue of subdomains not functioning properly in express.js?

Currently, I am conducting some local experiments and have made changes to my hosts file. Here are the entries: 127.0.0.1 example.dev 127.0.0.1 www.example.dev 127.0.0.1 api.example.dev Below is the code I am using: var subdomain = req ...

Fetching data from an Angular Universal server API

Recently, I updated my application to Angular 6 + Universal and it has been a positive experience overall. However, there are two specific issues that I am currently facing. I would greatly appreciate assistance in resolving both problems: 1- Is there a w ...

Guide to Making a Cookie Using Node's cookie-session Package

I'm currently working on a small node application and my goal is to have it create a cookie for every visitor, named 'session', which will store the session ID. However, I've been facing some challenges in getting node to generate this cookie using the coo ...

Encountering Issue H12 While Deploying an Express JS Application on Heroku

I have developed an application using Node JS, and I've taken it as far as I can on my local machine. Now, I need to deploy it on Heroku. If you want to check out the main server.js file, you can find it here: http://pastebin.com/6VGk8ESz. To understand h ...

Combining JWT authentication with access control lists: a comprehensive guide

I have successfully integrated passport with a JWT strategy, and it is functioning well. My jwt-protected routes are structured like this... app.get('/thingThatRequiresLogin/:id', passport.authenticate('jwt', { session: false }), thingThatRequiresLogin.fi ...

Error Alert: UnhandledPromiseRejectionWarning in Async Series Causes Concern

I am currently working on a function in my project that uses the async series method to ensure specific tasks are executed in a certain order. In this case, function1 needs to be completed before function2, which must then be completed before function3. a ...

Create a pipeable stream that does not trigger any events when data is piped

I have been trying to utilize the renderToPipeableStream function from React18, and although it is functional, I am struggling with handling the pipe properly. The key section of my code involves an array of strings representing HTML. I am splitting the s ...

What could be causing my function to return undefined instead of an array?

I have been working on a function to query my database and retrieve specific details for the selected item. While it successfully finds the items, it seems to be returning undefined. var recipefunc = function(name) { Item.find({name: name}, function ...

Handlebars does not support loading data into variables using Express

My NodeJS/Express application utilizes Handlebars for templates, and everything works smoothly except when attempting to display data retrieved from an Express API. The data is successfully fetched and can be viewed in the Chrome debugger. In the problem ...

Having trouble getting Node.js DEBUG=appname to work with nodemon on Windows?

I am currently following a Node.js tutorial by Mosh and I'm having trouble getting this line of code to work: DEBUG=app:db nodemon index.js When I try to run it, I encounter the error message: 'DEBUG' is not recognized as an internal or external ...

Why is the helpers folder so important in an Express application?

Exploring the ideal hybrid folder structure to meet our needs is my current project. After sifting through numerous resources and sources, I stumbled upon a folder labeled helpers housing files with a .js extension. |-- app | |-- controllers | | `- ...

What is the process for accessing data of signed-in users?

I currently have a mobile app developed using the MERN stack that utilizes passportjs for user authentication and login (linked to a mongodb database via axios). However, I am facing an issue where I cannot associate the data/log entered by the user with t ...

What is the best way to ensure the user document is saved when a new post is being created

Having resolved previous issues, my focus now is on populating the user document with posts. Here is the current structure of the user document: { "posts": [], "_id": "5e75cf827ef14514f69c6714", "username": "di ...

Comparing GraphQL Dataloader with Mongoose Populate

When it comes to performing a join-like operation, both GraphQL and Mongoose can be utilized for achieving the desired outcome. Before posing any inquiries, consider the following example related to Task/Activities (please note that this code is purely fo ...

Creating select options from a hash in Node, Express, and Jade: A step-by-step guide

Recently, I've been experimenting with node.js, express, and jade. I am attempting to create a select dropdown in a jade template like this: my-options = {"this": "something", "that": "something else", "those": "more stuff", "these": "also included"} for ...

What steps can be taken to adjust the Express route so that the user is automatically logged in upon creation in Mongodb?

I am currently working with the route provided below. The route functions properly when I manually add documents in MongoDB. However, I am interested in implementing a feature to handle scenarios where the user is not found, created, and then automatically ...

How to Populate .handlebars Templates with Multiple SQL Results in Express

As a newcomer to the world of Express and Node.js, I am eager to understand how to display multiple SQL results on different elements of a web page. Though it may be a simple question for some, I am unsure how to proceed and would greatly appreciate any g ...

I am currently experiencing issues with the app post feature as it is failing to generate any output

var express = require("express"); var app = express(); var bodyParser = require('body-parser'); var port = 3000; const fs = require('fs'); // establishing connection to MongoDB using Mongoose var mongoose = require("mongoose"); // Implementing bodyParser ...

What are the steps to incorporate metrics middleware for Socket IO notifications, specifically monitoring both emitted events and listener activity?

I am currently working on a project that involves tracking all socket.io notification transactions initiated by the server, resembling an API request/response counter to validate subscription validation. Our team is utilizing an express middleware to moni ...

Nginx reverse proxy throws a 'Cannot GET' error when connecting to socket.io on an express.js server

Recently, I followed a tutorial on setting up Node.js with Nginx on two Ubuntu 14.04 servers connected via private networking. The setup involves having Node.js running on myappserver (accessible via private IP myprivatewebserver and publicly via mypublica ...

The session is not being established despite the Set-Cookie header being transmitted

I am managing three services - be, fe, and auth. These services are all hosted on App Engine with a load balancer set up to keep them under the same domain. My goal is to create a session upon user login. The issue I'm facing is that even though the set-co ...

Rendering Information in Angular 4 Through Rest API

Encountering issues displaying data from my local express.js REST API, organized as follows: people: [{ surname: 'testsurname', name: 'testname', email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemai ...

The NodeJS server is struggling to fetch post data sent from Angular

I've developed a backend server using NodeJS with Express. On the frontend side, I'm working with the latest version of Angular. When I post data (GPG file) to the NodeJS server and try to retrieve it in my NodeJS code to output it on the server console, ...

Find and match additional routes easily after an initial one has been discovered

Currently, I am in the process of constructing a basic blog using Express 4.13.3 and Mongoose 4.2.4, however; there is an issue that I have encountered where subsequent routes continue to match even after one route has been matched, leading to the applicat ...

The flow of Express middleware

Imagine you have the following setup for an Express app: const express = require('express') const app = express() app.use((req, res, next) => { console.log('\n\nALWAYS') next() }) app.get('/a', (req, res) ...

The Express GET route does not support parameters or additional paths

I am facing an issue with making a fetch request when trying to add additional path or parameters... Here is what I want to achieve: const fetchOwnerCardList = () => { fetch("http://localhost:5000/api/card/ownerCards", { method: "GET", header ...

"Can someone explain the process of obtaining the chat invite link that allows a member to join using Node Telegram Bot API's #chatmemberupdated function

I'm currently working on a Telegram bot and I need to retrieve the chat invite link when a member joins a group. I've been using the node telegram bot API in NodeJS and following the "chatMemberUpdated" method as outlined in the official Telegram ...

Express middleware generator function causing a type error

I recently implemented a function that takes a middleware function, wraps it in a try-catch block, and then returns the modified middleware function. tryCatch.ts import { Request, Response, NextFunction } from "express"; export default function ...

Encountering NodeJs Error 401(Unauthorized) while implementing passport-jwt in my project

I am currently developing an authentication application using Node.js, MongoDB, and the Passport-JWT middleware. I have successfully implemented the login functionality and I am able to obtain a token. However, when trying to access the user profile after ...

Transferring information from nodejs/express to frontend JavaScript

I am faced with a challenge regarding accessing the 'data' sent from my backend server in my frontend js. Can anyone guide me on how to achieve this? Express ... app.get("/", (req, res) => { res.render("home", {data} ); }); ... home.ejs ... <sc ...

The message of error is undetermined

Can someone help me with using the errorMessage object from routes in a partial? I have attempted to implement it as shown below: Route:- const express = require("express"); const router = express.Router(); const Character = require("../models/character" ...

Looking for a list of events in Express.js?

I've been searching through the official documentation, but I couldn't find a list of events for express. Does anyone know if there's something like 'route-matched' so that I can use app.on('route-matched', () => {})? Edit: I did come across the mount ...

"Encountering a mongoose error when attempting to connect to MongoDB following the implementation of user authentication

Currently, I am utilizing mongodb on ubuntu 14.04 and executed a command to include a user in a database with readWrite permissions using the subsequent command - mongo Afterwards running use utthan-dev and then executing the following: db.createUser( ...

Using Node.js and Express to import a simple JavaScript file as a router

Can anyone help me understand how to import the user.json json file into my user.js? I want the json file to be displayed when typing /user but I'm struggling with the new version of Node. index.js import express from 'express'; import bodyParser from 'bo ...

Uploading an image to MongoDB using Mongoose

Hello everyone, I am just getting started with the MEAN stack and I'm looking to add a file upload feature to my project that will store uploaded files in a MongoDB database. Since my images are small, I don't think I need to use gridFS from MongoDB. Can a ...

A guide to configuring query variables in the server's response

Currently, I am operating an express application and there is a specific section where I need to send some data along with the page being served. The file is being sent using the res.sendFile() function. Ideally, I would like this data to be passed in the ...

unable to retrieve information from a function

I'm encountering an issue in this nodejs and expressJs project where I am unable to successfully retrieve data from one function. router.get('/', async(req, res) => { const meta = fetchMeta(); console.log('meta', meta) // ...

What could be the reason behind receiving a Req.Req (Nested request) when using this specific configuration in Express?

IMPORTANT NOTE: If you are experiencing issues with nested requests or responses, make sure to check the parameter order or utilize the express.router({mergeParams: true}) option. It seems like my requests are being encapsulated by an additional object re ...

Using Node.js with sqlite3 for seamless data synchronization

Recently, I've been experimenting with developing a basic app using nodejs, socket.io, and sqlite as the database system. This project is primarily for learning purposes to gain a better understanding of how nodejs functions and to determine its suita ...

I am receiving a null value without the presence of an error argument

I'm currently delving into the world of Express in conjunction with Mongoose. I encountered an issue while working on a page that involves running a forEach loop on a list of "campgrounds" fetched from a MongoDB. From what I understand, when using the .fin ...

Upon a successful AJAX post request, the page fails to display

I'm encountering an issue connecting my front-end JavaScript to my back-end Node/Express. Although the requests from my client-side js to the server return successful, the page I am requesting fails to render. On the server side, here is my code: app.get ...

CSRF Error: Unauthorized Access Detected in Express and NodeJS

I've been attempting to create CSRF tokens in my Express application. Despite looking at similar questions, I haven't found a solution. Below is the code snippet from my app.js file: var app = express(); var connect = require('connect' ...

The ongoing battle for routing supremacy between Express and Nginx

My current setup involves a unique configuration that I'll need to maintain until I have the opportunity to refactor the project later this year. Right now, it's a static index.html landing page being served with a root location "/" by NGINX. I& ...

Discover the secrets to unlocking IntelliSense for Express.js in Visual Studio Code

After attempting to install type definitions using: The javascript file where my code is located is server.js. npm install @types/express Unfortunately, I am still not receiving intellisense for the 'app' variable after initializing express. ...

express-flash-notification displays the following error message: "No default engine was specified and no extension was provided."

Recently, I started working with node.js and using MEAN stack for my project. In the footer of my project, I have an option to "Subscribe email". Due to constraints in the architecture, I am unable to utilize Angular for displaying flash messages as I don' ...

Nodejs does not automatically redirect to https connections

Currently, I have set up a node server with express on top. My domain registrar is GoDaddy. When trying to connect using www.example.com, it doesn't work, but it works fine with https://www.example.com. Below is the code snippet for reference: app.use(ex ...

What is the best way to securely store and retrieve API keys within a React application built with Webpack?

Currently developing a project using React, Babel, and Webpack on the front end. Need to find a secure way to store and access API keys for the project. Considering storing API keys in the .env file, which is listed in .gitignore to keep it private. Howe ...

What is the best way to utilize the handlebars-helpers library within an express.js application?

Currently I am using hbs as my template engine in express.js. The handlebars-helpers library from assemble is something that I find extremely useful. However, I am unsure about how to integrate this library into my project. I have also been unable to loca ...

What causes the 'PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR' error in a Node.js and Express application?

Trying my hand at building an application using Node and Express has been smooth sailing until today when I encountered this error: { code: "PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR", fatal: false } According to Google, I should switch from create ...

Choosing between creating a class with a shared instance or not

I'm curious if my class is shared across instances: for example, I have a route that looks like this: /student/:id When this route triggers the controller (simplified version): module.exports = RecalculateStudents; const recalculateActiveStudents = r ...

The Node.js application is unable to locate the source file path

Currently, I am in the process of creating a simple quiz application. While working on this project, I encountered an issue with linking a JS file in an HTML template. Even though I have confirmed that the path is correct, every time I run my node app, the ...

What is the purpose of requiring the explicit invocation of app.listen(port) to enable express-ws to function properly?

I've recently started exploring NodeJS Express and came across the official tutorial from express-ws for setting up websockets in a simple project generated using npx express-generator. While following the tutorial, I noticed that in the app.js file, ...

NodeJS Password Recovery

Recently, I implemented a password reset feature using NodeJS/Passport. I found an excellent guide: . I followed the instructions and it was mostly successful. However, there seems to be a critical error that I can't locate. When a user goes through the pr ...

What factors should you consider when deciding between NoSQL and SQL databases?

Here's my query: I am interested in learning Node.js/Express and creating a basic web project. The project would involve setting up a database with tables for users, video games, and categories. The website will simply display a list of games (for demonst ...

Do you think it's feasible to configure cookies for express-session to never expire?

Is there a way to make cookies never expire for express-session? If not, what is the maximum maxAge allowed? I came across some outdated information on setting cookie expiration on SO (over 10 years old) and here on express, which mentions a maxAge of 1 y ...

NodeJS: Implement session refresh mechanism following permission changes made by other users

Utilizing express-session in my NodeJS application for managing sessions, express-mysql-session to store session data in MariaDB, Passport for authentication, and Sequelize for ORM. Encountering an issue where I am unsure how to refresh a user's session a ...

Using TypeORM with a MySQL database to assign empty values to optional parameters

Currently, I am in the process of developing a GraphQL mutation for updating user account details within my application. These account details include fields for gender and birthday, both of which are optional. Here is an example of my InputType: @InputTyp ...

Every time I attempt to utilize tokens, I consistently encounter the error message "Login sessions require session support"

Currently, I am learning about JSON tokens through a tutorial and encountering an error. Previously, everything was functioning correctly with sessions, but now I can't seem to pinpoint the problem even though I'm using identical code. This snip ...

Combining Summernote images with Node.js using Express.js

While there are numerous solutions available for handling the Summernote file-upload in PHP, I have struggled to find a satisfactory solution for Node.js. Here is My JavaScript: $(document).ready(function() { // $('#summernote').summernote( ...

REST API Express - DELETE Endpoint

I'm facing an issue with the delete functionality in my API. In order to use my application, a user must log in and then they can add courses. These courses are stored in a nested array within the User model. I want users to be able to remove (delete) ...

Having difficulty constructing a full stack application using Express

I've been struggling to configure a full stack app using create-react-app with Express and TypeScript. My main issue is figuring out how to compile the server files into a build folder. I have separate tsconfig files for the server and create-react-app. T ...

Issue: ENOENT encountered with __dirname usage

When building my website using Express, I encountered an issue with my code in server.js: app.use(express.static('public')); app.get('/add', function (req, res) { res.sendFile(__dirname + "/" + "add.htm");}) The structure of my projec ...

What is the process for displaying data submitted through a form on page B to page A using Node and Express?

Dealing with the issue Hello everyone. I've been struggling for the past 30 minutes trying to figure out the rendering method problem I'm facing. Whenever I try to post data through a form from Page A and then render that data on Page B, I keep encounteri ...

Heroku App Breaks Down - Fails to Render Static HTML Content (Express Server)

Despite my best efforts, I keep encountering this persistent error on Heroku whenever I attempt to serve a static HTML page with some basic JS, images, and CSS. I diligently followed all the advice from SO, made adjustments to index.js, restructured files, ...

Storing Documents and Distributing them to Customers (Using NodeJS, Express, MongoDB, and Mongoose)

Is there a way to save files in mongoose? For instance, let's say I have a route for the POST method at /, and for the GET method at /. When posting to /, the goal is to save the uploaded file to a MongoDB database using mongoose. Then, when someone t ...

Having trouble with integrating user input from HTML into a JavaScript file to execute a GET request

I am currently working on a project to create a website that integrates the google books API for users to search for books. To start, I have set up a server using express in index.js at the root of the project directory, and all my static files are stored ...

Does the CORS error pertain only to the nginx server, or do I need to make changes to my code as

After successfully deploying my website for the first time, I encountered an issue with data not being properly sent from the contact form to our node.js server and then to our email address via nodemailer. The error message "Access to XMLHttpRequest at 'h ...

The error message states that the property "user" is not found in the type "Session & Partial<SessionData>"

I recently had a javascript code that I'm now attempting to convert into typescript route.get('/order', async(req,res) => { var sessionData = req.session; if(typeof sessionData.user === 'undefined') { ...

The only information returned from calling mongoose's Model.save() method are the fields { _id, __

I've encountered a problem even though I believe I'm following all the right steps. I'm attempting to save an item from a form into my mongodb collection using mongoose. This is what my schema looks like: // stationmodel.js export const Sta ...