Newest express Questions

Q&A for professional and enthusiast programmers

req.body empty out of nowhere when sending POST with express and node

I have a node app on heroku that is using express to act as a REST API. On thursday and friday of last week, it was working just fine, when i would post using REST Easy through firefox. I hop on ...

Configuring an express server to serve my webpack production site

I've been working on an Angular 2/Webpack project that I bought through a template which already had a webpack development and production server. They go as followed: webpack.config.js: // Look in ...

Is the routing of express.router() synchronous?

This has been baffling me... This following test shows that requests are being received asynchronously, responded to asynchronously, yet all requests are first received, then responded to... Given the ...

sending file to client for download

Hello I am trying to send a file from my express server to my front end to allow the user to download it when they click a button. I've created a route on the backend the sends over the byte array but ...

node.js - Static files CSS / JS not working in express

I Understand many people have asked the same question but i just can't get this to work for me at all. I am trying to make a socket.IO application and are following the tutorials but just can't get ...

TDD Test first Nodejs express Rest Api - unit testing middlewere / controllers / routes

I'm trying to figure out how to test first my node js rest api app. so far i've been using nock to intercept and mock any http call and by that test my service as a component. (component testing?) i ...

Using a node module within a node application

I'm extremely new to node.js and working with node modules so any help would be much appreciated. I am trying to use the treant.js library to generate svg tree's within my application. I simply want ...

Send same data to view in POST and GET in node.js / Express.js

Initially I tried to use the router.post and router.get methods and have them separated in my code. Then I opted to use router.all, and within the same function separate POST and GET and use two res....

How does React server-side rendering deal with RESTful API (react-router+express)?

I've got a problem with react SSR. I use react-router as my app route manager. In the server side, it may look like this (server.js): var app = express(); app.get("*",function(req, res ){ ...

Why is this simple express server running on two ports?

I have simple node server, like so: var express = require('express'); var request = require('request'); var apiServerHost = "http://<IP address>:3000/api#!/" var app = express(); app.use('/...

Addition of continuation-local-storage causing CPU leak

After adding cls to an express node app the CPU usage of the application steadily goes up over time when under a constant load. Remove cls and the problem goes away. What tools and/or techniques can ...

error handling with firebase nodejs/express

I have the following in index.js: router.post('/signup', function(err, req, res, next){ var username = req.body.username; var fname = req.body.fname; var lname = req.body.lname; var ...

How do I measure performance of mongodb client connect in express.js?

I'm inclined to call MongoClient.connect on each http request (app.get, app.post etc) rather wrapping each request handler in the connect callback. How can I measure the performance tradeoffs?

Express can't use app.get

I'm trying to create extra routes, however, whatever I try I always get "Cannot GET /x" error. What could be the reason? Here's my server.js file; var express = require('express'); var app = express(...

Material UI -Autocomplete how to get event.type or an extra attribute name?

I am creating a handler to process user input. According to documentation I am using onUpdateInput to get the value which is selected but how do I assign a name and get event.type from <...

express PUT empty body

I am working on making an update request in my REST api built in MEAN Stack. While submitting a HTTP PUT requrst, i am getting 'req.body' always empty. I have explored already and i am using ...

securing paths and static files with passportjs and expressjs?

I am trying to create an api restful server, and i am using expressjs to host the server and passportjs for authentication. for the meantime I am using the basic authentication Username:password ...

TypeError: db.collection.createIndex is not a function in Search functionality for express project

Using the code below I get the error TypeError: db.collection.createIndex is not a function, which I want to use to implement the search functionality from this site: https://docs.mongodb.com/manual/...

Passing variables from Expressjs to Angular2 [on hold]

I have used expressjs to create server for angular 2 instead of lite-server. And now, I have a variable in express.js file but I dont know how to pass that var to typescript in angular 2. So anybody ...

Why does res.sendFile path need the same directory as in the express.static?

I spent a long time on my app confused why the wrong index.html file was showing and I found the solution but I don't understand why. I have two html files: One in a public directory and another in ...

Certain routes go to 404 error page express

I am setting up my first node project. I had all the pages working nicely until I started to move some thing around. I have done all of my routing for different pages in index.js. I have changed that ...

Why my injected mongoose models do not return documents when calling find()?

I have a service module that saves and retrieves documents from a mongo collection in Mongo Atlas. This service module is a thin wrapper around mongoose, and I'm injecting mongoose and its models ...

Centralized Error Handling & Reporting for node.js

I want to have a system which will either send me a text message or email based on severity of error on respective occurrence. I have done some research on the subject but I haven't been able to ...

Editing ExpressJs project generation

Id like to edit the default expressjs project to generate a folder structure a little bit different than the one that they use now and to also generate a different layout.pug file and include some ...

ExpressJS Static not working

Been having some issues with express, I can't seem to serve static files. If I do : app.use('/*', express.static(DIST_FILEPATH)); it gives me a 301 or something, basically doesn't find the file (I ...

Access AJAX POST data with Node.js/Express

I'm building a web application that uses Node.js/Express for the backend. In my front end, I am sending an AJAX request to the server through Javascript that looks likes this: var xhttp = new ...

How to app.get after redirecting using express in node js

I'm a newbie in node js and here is my question. I set the code in app.js to redirect after logging in from the login page as below, app.post('/login', function(req, res, next) { passport....

Facebook Login Flow For REST API

I want to integrate Facebook login into our app (android, iOS and webapp) . The backend server is built with Express (Node) and MySQL. I have thought of the authentication and authorisation flow of ...

ERR_SSL_PROTOCOL_ERROR with Heroku, Node, Express, SSL

I recently enabled SSL for my Heroku-hosted website, wildcodemonkey.com, but when I visit it in Chrome I see the error "ERR_SSL_PROTOCOL_ERROR". My research indicated that the SSL connection ...

Cannot serve angular 2 index.html file from express server due to path relativity issue

This is my app folder structure with the angular-client folder The below picture shows the issue where when I server the index file of angular app from express server , all the gets are relative to ...

Adding chinese character to XML- node js

I have build an xml which contains chinese characters: I have used node package xml-writer. code: xw = new XMLWriter; xw.startDocument('1.0', 'UTF-8'); xw.startElement('Orders'); xw.startElement('...

Express Node accept request after running initial code

I have an app with express and socket.io. I make request to 3d party api and store the response data in array: var codes = ['a', 'b', 'c'] var results=[] var calls = codes.map(code=>{ var url ...

getting empty array on express response

I am working on an example, I am trying to get a single employee instance from this express example, but when I type, localhost:3000/1, I am getting an empty array. does anyone know what I am doing ...

How to properly structure an update statement for many-to-many relationship in mongoose?

My app is a simple node/express/mongoose classified ads app. I am trying to model the following relationship. I have a listings collection and a categories collection. Each listing may be in many ...

Object not mutating

Trying to mutate objects in a for loop. I am expecting console.log(dish) to log the dish object with an ingredients property containing an array of unshifted ingredients. When I log dish....

Send data along with html file using res.render() in express.js/node.js

How to access variable "name" in index.html file using res.render? app.get("/", function(req, res){ res.render('index.html',{name: "xyz"}); }); Following is the example of codeigniter, I want to ...

Create a session-dependent temporary file address

I want to build a simple playground with MEAN stack that has a subset of functionalities of plunker. The way plunker executes a set of files (eg, html, css, js) is that it saves the files in their ...

how to use socket.io for fetching data and update it on every instance in nodejs and angularjs

//Client side Socket.io socket.on('updateFnolList', function (data) { console.log(data);`enter code here` getUserInfo(); }); //server side router.get('/', function(req, res, next) { // ...

Webpack help - add hot loading and source mapping to a React / Node Project

I'm a webpack newbie. I'm trying to add React to a simple Node project but I've only ever used React with a pre set up webpack dev server and not with another server. Webpack runs it's own node server ...

NODEJS how to connect several express.method() via middleware

I have built , using express() , a variety of methods. for simplicity let's I assume I built 2 POST() functions and I want to be able to use them by themselves and also to concatenate them via ...

nodejs Architecture with multiple sets of data per page

Background Information I am making a visual display system using NodeJS and Express that will get information from multiple sources, format them and display them as slides in a full page site on a TV ...

include client side js in express.js

I've build a new app with an express-generator so i've got public dir with javascripts i guess for a client side. But i can't get access to this files. My app.js has for an absolute path app.use(...

session save in nodejs

I am using express-session-sequelize. server.js var http = require('http'), express = require('express'), app = express(), config = require('./config/config'), routes = require('./...

How to detect unexpected end of request in Express while the request body is being piped into a child process stdin

I have a child process spawned in my Node.js app, the request body payload is piped directly to the child stdin. Even though the client TCP socket is closed, no relevant events are omitted. What I ...

Route always ends up on Detect Region Page?

I am using express-subdomain and am having trouble to get the subdomain routes to function. Here is what i have: var subdomain = require('express-subdomain'); var express = require('express'); var ...

Client-side cannot locate socket.io.js

I've read all other posts on this topic but I cannot find answer for my problem. I have Express server running on default port or 5000 (process.env.PORT || 5000). I then added socket.io but client-...

Can not Get value req.body.value in form, please help me?

html form <form method="post" action="/login"> <input type="text" name="user_vi" placeholder="User name vi" value="usernametest"> <input type="text" name="email_vi" placeholder=...

Why node js Active Directory results in etimedout?

I am using node js express framework. My Active Directory is not connecting and it always results in the following error "code":"ETIMEDOUT","errno":"ETIMEDOUT","syscall":"connect" This is my code ...

Getting node.js app to read data from MongoDB with Auth turned on

Pretty new to MEAN stack development; I'm trying to get my app to display data from a MonogoDB collection. So far, I've got the data to display when MongoDB auth is turned OFF, which of course, I don'...

passing the session data from passport to redis in production

I am trying to pass the session from passport after authenticating, and store the data session to redis. I've read some articles that passport can't handle session during live production and so I have ...
Translating... 0%