Questions tagged [express]

20850 questions
0

votes
2

answer
45

Views

Want to create an array of array in nodejs(javascript)

I want to create array of array using given record. user_permission = [ { _id: 1, description: 'chairman list', main_module: 'admin', sub_module: 'admin' }, { _id: 2, description: 'create chairman get method', main_module: 'admin', sub_module: 'admin' }, { _id: 3, description: 'create chairman post...
Amit Patel
0

votes
2

answer
13

Views

Exclude _id field from JSON response Node js

I want to exclude default _id field while fetching the data result from JSON API in my node-express app. I tried several ways to do so but still the data shows _id in GET response. Here are some of the ways I figured out that didn't worked: exports.get_all_clothing = (req, res, next) => { Clothing.f...
bubble-cord
1

votes
3

answer
7.1k

Views

Node.js sending an email with image attachment using nodemailer

I'm trying to send an email from a post request. I'm using Express and nodemailer. I'm confused by 'fs' My email is getting sent but the image is not included as an attachment. I checked the docs but they all seem to send up static files not files being streamed in from a form request. var smtpTrans...
PaulWoodIII
1

votes
1

answer
81

Views

How to deploy expressjs static templates to AWS without restarting the server?

I have express.js server server that I deploy to AWS elastic beanstalk. I use handlebars engine for templating. Templates structure changes more often than server code so I want to have a fast way to deploy them. I have experimented with hosting templates on separate S3 static bucket and then loadin...
brisky
0

votes
1

answer
3k

Views

TypeError: path must be a string or Buffer MEAN stack

I am using Angular 5 on front-end, Node on back-end and Mongo as the database. Now I am trying to save an image to the database but constantly getting this error. I can't figure out if I'm making mistake on front or back because this is my first time working with files. I did my research but it poin...
JKshort
1

votes
1

answer
112

Views

Can't require renderer in http protocol in electron

Can anyone explain me why this code is not working? I tried to require the renderer in file protocol (without express static server) and it was fine, but when i do this with http protocol i got Uncaught Error: Cannot find module './renderer' ! Is there any way to require custom modules in http? Than...
Sadra Samadi
1

votes
0

answer
36

Views

Visual Studio 2017 Stops Debugging When Navigating Away From Site Being Debugged

This has been driving me crazy... Running a solution works with no problems. I can navigate within the application with no issues. The problem arises when I navigate to a site outside of the debugging site, i.e. I go to a site outside of localhost. The reason to go outside the site is to authenticat...
AntLaC
1

votes
2

answer
54

Views

How to remove an element from an array within Mongo

I'm completely stuck with Mongoose and remove method. I have a page with comments and form with a button Delete. My goal is to delete only that comment which was clicked. Below is my MongoDB file (By the way I use method override of the express library to handle both request post and delete). { '_i...
Ar2zee
1

votes
1

answer
57

Views

Monk addToSet rewrites array

When I use Monk's addToSet in my route /upload-ajax, the array just rewrites itself with the first new element. Here is my code: const express = require('express'); const router = express.Router(); const debug = require('debug')('hackit:images'); const boom = require('boom'); const fs = require('fs'...
Mikita Melnikau
1

votes
1

answer
51

Views

express js render without replacing html tags (like <p>)

I'm working on blog-like project and I need to render text without replacing html tags. ./app.js //app.js ... var text = 'Hello World' app.get('/', (req, res)=>{ res.render('index', { text: text }); }); ... ./views/index.jade //-index.jade p= text When I render this: Here is what I'm getting: Hello...
Otabek Keldiyorov
1

votes
1

answer
794

Views

Root Route Not Redirecting in Express

My issue stems around strictly the '/' route. I think this is called the root route. When a user connects to my site, I check to see if there's session data on the said user so that he/she doesn't always have to re-log when the browser closes. If there is no session data on the user, then my website...
Programmer wannabe
0

votes
0

answer
2

Views

res.redirect() searching but not loading

i'm trying to redirect a user to a page after checking his credentials through a post method. the thing is the page after the res.redirect function keeps trying to redirect but never does. app.post('/login', function (req, res) { MongoClient.connect(url, function(err, db){ if (err) throw err; var...
NeoK
0

votes
0

answer
2

Views

How to effectively protect routes in combination with react-router and passport on the backend

I have React and Node.js with passport.js on the backend which implements my app auth. My react makes a call to my backend and fetches the authorized user via action reducer. Everything works fine but there is a problem with the route guards. This is how I am protecting the routes if the user is not...
1

votes
0

answer
107

Views

Accessing Object inside of Mongoose Field

I am trying to create a new user using mongoose and express. I am attempting to add a profile picture to the users Schema. I already have everything working, with the exception of the profile picture. I do not know how to access the buffer and contentType properties for the Schema.
Ellington Crevier
1

votes
0

answer
95

Views

NodeJS, MySQL, Express - Pluggable Modules

We are trying to develop a pluggable application with NodeJS and Express backed with MySQL. We are trying to achieve a pluggable framework in which there will be a /plugins folder that will contain custom modules. The modules will be require()'d based on which is active. The active / inactive state...
Sameer Joshi
1

votes
2

answer
63

Views

connection between client-side and server-side not working on socket.io

I have problem with socket connection between client-side and server-side . I have this code on server-side :- var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); io.on('connection', function(socket) { console.log('a user connected'); socket.o...
ali al-shelleh
1

votes
1

answer
39

Views

Express OAuth Authorization for Different Access Methods

I am looking to figure out best practices for the following scenario. I am a relatively new/hobby programmer. I am developing a chat bot that is using Dialogflow. I want users to be able to use different messaging apps to be able to access the data and information in a backed database, but that I...
Mike Nelson
1

votes
1

answer
1.9k

Views

Node js error “process with a non-zero exit code”

I developing a REST API using node js and express with MongoDB. I have developed an endpoint to insert the user into DB and works fine. Now I have added the login function with jwt and now when I run my app and try to insert my user I receive this error: an app is listening on port 3000 (node:3650)...
user5858205
1

votes
0

answer
54

Views

Express Node.js client-sessions throwing error of undefined

I am trying to set a cookie session using client-sessions. I think everything should work. but it is giving me the error [TypeError: Cannot read property 'isAdmin' of undefined]. I am failing to see what I am doing wrong. Thanks in advance! var session = require('client-sessions'); app.use(session({...
Cory Sparks
1

votes
1

answer
113

Views

Can't get handlebars partials to work with Express

I'm new to express and handlebars and I'm trying to make some basic templating using partials... I'm getting a 'partial could not be found' error. dependencies in package.json file 'dependencies': { 'body-parser': '~1.18.2', 'cookie-parser': '~1.4.3', 'debug': '~2.6.9', 'express': '~4.15.5', 'hbs':...
Corey Bush
1

votes
2

answer
443

Views

How can one set process.env variables on their localhost in Express?

I want my code to run for both testing on my localhost, as well as my server. In heroku there is a GUI to do this, but how do I set these locally?
1

votes
2

answer
171

Views

Error installing Express via nodejs

I'm trying to install express via nodeJS and the errors that I am getting tell me that I should rename my directories. I have already run npm init in my project folder so I assume the setup is correct. The exact command that I use is: npm install express --save and the npm-debug.log lists a bunch of...
Nayman Leung
1

votes
1

answer
36

Views

Make 2 modules in 1 project

I have a mean-stack project. In my index.js, I have in the end router.get('*', function(req, res) { res.sendfile('./views/index.html'); }) module.exports = router; Now I want to treat all the webpages matching https://localhost:3000/1/addin/* by ./views/addinIndex.html, where I expect to refer to di...
SoftTimur
1

votes
0

answer
112

Views

Alamofire post data not sending expressjs

I'm trying to send JSON data from IOS Application using Alamofire to a express server. But I'm not able to retrieve the data in the express application when I check the data being logged out it displays a empty object. I can't figure out why I'm not retrieving the data in the express application. B...
BrentG
1

votes
1

answer
403

Views

Define MongoDB Collection in REST API GET Request

I have data in 2 seperate collections stored in the same MongoDB database. Is there a way to define in the HTTP GET request query string from which collection the data should be retrieved. I use the following JS to process the query: const findDocuments = function(db, callback) { const collection =...
Sebs030
1

votes
0

answer
784

Views

Generate Swagger Documentation for existing NodeJS server

I'm trying to document my API using Swagger, but if I do the documentation by myself and manually, I'll spent a lot of time, and then I saw this question on SO, and the last answer is about the express-oas-generator that seem's to be a good tool. Generated my documentation with success, but the POS...
Lucas_Santos
1

votes
1

answer
68

Views

Changed MessageClass of unread mail item in “Unread Mail” folder cannot be saved without error

I've got a custom Outlook 2013+ add-in using Add-In Express with a button on the main Ribbon that when clicked changes the message class of the selected mail item (amongst other actually-useful operations). This works fine in all situations except for if the currently selected folder in Outlook is...
Pablissimo
1

votes
3

answer
622

Views

CORS issue (Express backend, Angular frontend)

I'm using Angular for my frontend, and Express for backend. I ran into a CORS problem with one of several api endpoints which are similarly configured: Failed to load http://localhost:3000/api/deletePost: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://lo...
Edwin Chua
1

votes
0

answer
188

Views

Which google Oauth options to use to for express API and react App

I have been in circles on this for hours and read dozens of blogs, articles, how-tos, SO questions, and documentation. What I am trying to do: I have a react application that talks to a node/express API. I would like to authenticate requests to certain routes using only Google OAuth. I would a...
red6
1

votes
1

answer
174

Views

Express Routes serving up as expected on local machine. But not when on Nginx

Routes serving up as expected on my local machine. But not serving up /public or /api routes. I've setup a serverblock for node.mydomain.com, installed a node app, and am getting 404 errors for all the routes express is supposed to be serving (static and api). node.mydomain.com => /public/index.htm...
Alice
1

votes
1

answer
779

Views

Express server add ssl

I followed the angular server-side rendering tutorial and created an express server. How can I add SSL support? I found how to add SSL in server.js but I don't know how to add it in Typescript. server.ts import 'zone.js/dist/zone-node'; import 'reflect-metadata'; import { renderModuleFactory } fro...
Maurice
-1

votes
1

answer
486

Views

Nested Promise is not propagating error to parent Promise in Node.js?

I'm creating an API using Node.js/TypeScript running Express. Below is an excerpt from my get method. An error is being triggered in the format method, which throws an error that is caught by the promise, but not propagated to the parent promise after a throw: this.getModel(objectName).findAll(query...
NobleUplift
1

votes
0

answer
38

Views

Scrape data from PDF that has three columns of tables using javascript

PDF with 3 columns of table Data I am trying to take the data from the linked PDF. It has three columns of data. And each column is formatted differently. I've tried several packages from NPM that are for reading and parsing PDF's but I can't find documentation to help me figure them out. And re-wo...
BVeth
1

votes
1

answer
34

Views

how to fix new mongoose module and nodejs - just happen from yesterday

I just open new project and i try to connect to my Collection i install my mongoose module like i do all the time but this time when i try to load my simple code: (that work if i copy the mongoose module that i have in another Project(that i install 2 weeks ago): var mongoose = require('mongoose') m...
ofer
1

votes
1

answer
91

Views

TypeError: Cannot read property 'text' of undefined

router.post('/addtodo', (req, res, next) => { let todo = new Todos({ text: req.body.text, date: new Date(), }); Todos.addTodo(todo, (err, todos, next) => { if(err) throw err; res.json(todos); }); }); I am trying to save a document in the Todo schema using the above method Schema and methods are as f...
1

votes
1

answer
262

Views

How to render an html template from express, while on Angular5

So, I ran into a fairly unique situation. I was tasked to convert an existing repository that's running server-side express and html as its view engine, to express with client-side Angular (5). I got stuck, when I arrived at an html view that I couldn't convert to Angular, and would like to have exp...
David Lee
1

votes
0

answer
15

Views

How to stop express from incorrectly interpreting path inside of static index.htm file

I'm testing express and I ran across a problem that I haven't found a good solution for. My relative paths inside of index.htm are getting confused by a route. Inside of server.js I include the following basic route. server.js app.get('/', function(request, response) { response.sendFile(path.join(_...
DR01D
1

votes
2

answer
456

Views

Express with Azure cosmos DB

Working with express(nodejs), mongoose, and Azure Cosmos DB to return objects. When I connect to my local mongodb, the following code correctly returns a list of commit objects that exist in local mongodb. Commit .find({}, function(err, commits) { if (err) { res.render('search/index', {}); } else {...
Daisuke SHIBATO
1

votes
1

answer
49

Views

expressjs setting tls connect https nginx server for request

How can set the request of expressjs to properly identify a TLS connection with https nginx server so that I can perform authentication through getPeerCertificate? this is my nginx config to transfer request to expressjs api location /api { proxy_pass http://10.88.132.14:4337/api; proxy_http_ve...
BaoBao
1

votes
0

answer
61

Views

How to sent from select table data to the backend so i can download somthing selected?

Hi guys im working on project and i want to use this table http://www.material-ui.com/#/components/table after fix everything and make it work with my project i have this problem what i want is to sent the information of the select one in the frontend to the back end so i can download the selected...
Anas

View additional questions