Newest express Questions

Q&A for professional and enthusiast programmers

How to have client call serverside (nodejs) script

When a user makes a selection, I want to populate a text box with the results of a query that is run from the server. The script and query work fine. I've tested it with a click event. However, I'd ...

Where to find which port is used by Google Compute Engine VM - NodeJS Compute Engine

So i'm pretty new to server-side cloud services (AWS, Google, etc). I've spent a day or so going through all tutorials and guides i could find out there in terms of getting a Node instance up and ...

JSON parse error: unrecognised token <

I am trying to implement user registration in my app. I used node.js express to create my backend and passed a insert query in a .js file i created in the router folder. I have added all the necessary ...

Mongoose CastError on updating collection

I got two collection on my mongodb databse which is room and question. I can add just fine, but when i tried to edit the question collection, i got this error This is my code for updating it, and ...

mongoose when res json is called, it is being executed twice instead of once

I am having a really hard time, understanding why it is executing res.json() twice. // GET - Get MY Applications router.get('/myApplications', function(req, res) { var taskid; var app_length;...

Expressjs Template Engine Choice

We are building huge e-commerce site with MEAN stack and we need to select a template engine immediately. We indecisive between nunjucks and pug. The most important point for us is performance and ...

What level does morgan use in conjunction with winston?

I'm currently learning about logging in the context of nodejs. Currently my setup uses morgan as express middleware and winston as my logging. My question is what level of logging does morgan use? ...

CORS error in express.js, despite use of cors npm package

My Express.js server is running on port 3001, and my React front-end is running on port 3000. I've set up the cors npm package with npm install cors --save and configured it like so: var express = ...

Developing interactive web-based musical scores

I'm a composer developing interactive web-based musical scores for a performance in May 2017. My idea is to network between four performers so that decisions made by one performer affect the scores ...

Sequelize - Associate table column value in where condition

Sequelize - Associate table column in where condition I want to perform this query in sequelize models: SELECT * FROM `model_game` AS `Game` INNER JOIN `model_activity` AS `Activity` ON `Game`.`...

create a WebApp using React, Node and Express

I need a little help with my WebApp So i started working with NodeJs and Express and now i want to integrate some React on my EditProfile page. So how can i do it ? I tried somthing simple like ...

Proxy nodej.js HTTP Server to another node.js HTTP Server which is connected as client

I have an local node.js HTTP Server which is connected to an extern node.js express Server using socket.io-client. I want to proxy incoming requests on the extern server to the local server which is ...

Mongoose - $and not functioning properly, need to find array with both items

I've got a chat based application that I'm working on. A private message between two individuals is a Chat model, which looks like this: let schema = new Schema({ members: [{ type: ObjectId, ref: ...

flash-connect into express with jade

I cant undestand why it dont working. I make into express route User.createUser(newUser, function(err,user){ if(err) throw err; console.log(user); }); req.flash('info', 'Flash Message Added')...

Multer not uploading the image in express app

I have written this simple application to test multer to upload files into my server. I am trying to test this using postman where I have selected form-data option, added a key to my image and ...

Multilingual validation message with Mongo Schema and i18n

I'm new to Node.js/Mongo and I was wondering how I could use i18n with my validation. So far here's what I have Schema const UserSchema = new Schema({ language: { type: String, ...

Upload file/images from react js frontend to express js backend without using extra libraries

I have written a react front end to upload an image that I can send to the server in a REST API. Here is the code, I have attached the file to the form data object and the post function is just a ...

node js save and retrieve session data

I'm trying to save and retrieve session data using node js. This is the code that save the id of the user: var express = require("express"); var cookieParser = require('cookie-parser'); var ...

How to pass the value from JavaScript to html through post method

The demo code of monaco editor is following. And I can't get the editor value through post method. I'm using Express. But req.body can only get the value from the tags that have the attribute name. ...

less loader not working with webpack 1

Installed less-loader still got error of You may need an appropriate loader to handle this file type. I'm using webpack 1 so I guess this is the correct config? { test: /\.less$/, loader: '...

Generate a Save File dialog in browser using blob content as the file

I want to export an HTML canvas as an image on click of a button. My approach so far is to wrap the button in an anchor and onclick, send a request to my API to generate the save as dialog by setting ...

How to pass ejs message into angular?

I am doing a mean app project and right now so far all my backend work from, express, passport and the csrf token and the flash message. The tricky part now is how to get it to the client side and I ...

CORS on POST using res.redirect

This code worked as expected app.get('/:phonenum', (req, res) => { var source = req.header('user-agent'); var ua = useragent.parse(source); if (ua.isDesktop) { res.status(308)....

serve receives drawing data sent by paperjs and emits it to all clients but no drawing appears(sockets javascript)

I am building a collaborative drawing website using Node.js, sockets and papr.js. the problem is event.point is sent correctly to all clients and clients received it but the drawing dose not appear. I ...

Failed to decode param in express

Whenever something like this: http://localhost:3000/asdd%Asd is typed in (obviously not a route) I get Failed to decode param. How would I catch this error and redirect to a 404 using a route? ...

node server crashing on uncaught exception

what is the best strategy to make node server not crash on uncaught exceptions? I have a web application in node. Whenever some uncaught error happens , server fails completely.we have to go to ...

NodeJS 'Can\'t set headers after they are sent.'

I build an app with Express fetching twits from twitter. Each call is fetching 200 twits (or less if the number is smaller) and total amount is 1800. I use time interval to fetch twits few times and ...

Bcrypt hash is undefined

So in one of my modules i have this function to hash a user's password. bCrypt.genSalt(saltRounds, function(err, salt) { console.log("Salt = " + salt) bCrypt.hash(this.userPassword, salt, ...

Requests for JS and CSS giving index.html instead

I'm using Express and create-react-app. My React app is a ways along, and now I'm trying to serve it from an Express server. // server/app.js const express = require('express'); const path = ...

Why doesn't push move results from DB query into variable?

Intent Establishing a connection with a DB in my route, running a query, capturing the result, and making it accessible to my index view to render in the DOM. Problem DB connects and returns ...

Attach http.Server to express Route

Is it possible to attach a http.Server object as a middleware to an express Router? I have an external library that generates a raw http.Server, but since I also use an express web server, I need to ...

Express js server giving ERR_EMPTY_RESPONSE

i'm having a serious issue with an app i'm building with node.js and express.js. the app converts videos to mp3. when the video is small upto 5min length everything work as expected, the http server ...

How to set up HTTPS using Lets Encrypt, Node, and Express 4

What I've Done I used certbot to certify that I own my domain, which generated several .pem files. The certificates are listed here: https://certbot.eff.org/docs/using.html#where-are-my-certificates ...

React + Express - What to serve instead of /build when in development

I used create-react-app to initialize my React app, and I am now serving the React client app from an Express server. My app structure is project/ build/ server/ src/ where my Express server ...

How to update this model that contains an array of objects in mongoose

I was wondering how I can update the array of likes with mongoose: var postSchema = new mongoose.Schema({ author: String, content: String, date: String, likes: [{theID: String}], ...

Neo4j JavaScript driver (bolt) Cypher query by id not working => error: Expected entity id to be an integral value

I'm new to Neo4j, working on a React + Express + Node + Neo4j app. I got the error message Expected entity id to be an integral value when I do this query. But if I changed the $id to a ...

Access denied for user ''@'localhost' (Visual Studio 2017)

When I try to launch my website I get an error saying that this user that I've never heard of has no permission to do something. When I try to delete him/her I get an stating that the user does not ...

Bootstrap Collapse is not working with dust

I am very new to express js and bootstrap. I am using Dust view engine. Everything was working fine except the collapse functionality.It is not working. My layout.dust file include jquery and ...

How to print the response body (or the request body when POST) in Node.js using Express?

var express = require('express'); var bodyParser = require('body-parser'); var mongoose = require('mongoose'); mongoose.Promise = require('bluebird'); mongoose.connect("mongodb://localhost/placement-...

Linking react and express

I am stuck trying to link express with react. here is my webpack file var debug = process.env.NODE_ENV !== "production"; var webpack = require('webpack'); var path = require('path'); module.exports ...

Passing Session Cookie to Front end (Backend Functional)

So I am quite new to this, and have a tight timeline, so here goes nothing. I am trying to create a login system using express and passport for the backend, and react redux in the front end wrapped ...

Environment for react-node application [on hold]

What is the best way to setup dev environment for production and development for react-node application which includes all the configurations of database and express configuration

Socket.IO keeps reconnecting Websocket on Cloudflare

I have a Node/Express app on server dedicated to sockets and on the client it's Angular 1.5. Running the code locally on http using the same architecture e.g. separate socket server it all works ...

node letsencrypt port confusion

So I have a node/express application and I'm trying to setup HTTPS with letsencrypt, more specifically greenlock-express. I'm a little confused on the logic here and how to set this up properly. In ...

Is it good practice to connect to the db multiple times?

I am using MongoDB, so I am connecting trough MongoClient.connect but I have to use that, for every route where I want to work with the database. Tried to preload it to an object, but then the ...

Embedding schemas is giving error

I am trying to embed schemas in other schemas that I have created, and I keep getting this error: I am not entirely sure what is going wrong here, but what I want to do is store references to my ...

Always returning 500 error

var express = require('express'); var router = express.Router(); router.post("/", function(req, res, next) { console.log('Yes1'); if(!req.body.username || !req.body.password){ console.log('Yes2'); ...

Do I need to define a Schema when using Mongoose to obtain data from CSV file imported to MongoDB?

I used mongoimport to add a csv file into MongoDB. In my node.js application I planned to create a Mongoose model to access that data however I'm confused as to whether I need to create a Schema in ...

nodejs - Hanlde a cpu intensive route

I am writing a express js app.There is one route when hit makes a schedule and give the generated schedule to the user as response. Its a little cpu intensive task. So as far i know running a cpu ...

using the feed dialog with facebook-node-sdk

I'm really confused about using facebook-node-sdk to implement a feed dialog. I would appreciate any help. Facebook shows an example of how to use a feed dialog using frontend code with FB.ui({ but ...
Translating... 0%