express

Using fs.extra copyRecursive gives a “TypeError: forEachAsync is not a function” error and I can't fix it

拈花ヽ惹草 提交于 2021-01-29 08:09:32
问题 My code is : http://pastebin.com/rCy4wSUK As soon as this function is called by router it prints "done copying contents of clean base into temp" and then error which is here: http://pastebin.com/UxEu4PaS So at least it is not giving an error in copying but what is causing it to throw this error. 回答1: Sounds like the fs.extra module has not installed completely and is missing a dependency. Your code runs fine for me with a fresh npm install fs.extra q Remove your node_modules folder and re-run

on postman get session returns as expected, on chrome not

早过忘川 提交于 2021-01-29 08:05:41
问题 im using passport js express, when i login and get req.user on postman it works as i expect. But when i try on web browsers(im doing get request with axios) its doesnt work. The problem is passport.deserialize doesnt work on axios get. i tried different http get request methods (fetch, jquery.get, axios) its not about that. Also when i do manuel request to my server it turns as expected. I have different project, code is nearly same and works on that. I cant understand what is the problem.

Express + CloudFlare with SSL

大兔子大兔子 提交于 2021-01-29 08:02:18
问题 I have an express app freshly created using express appName . I've changed the port to 443. The domain is under CloudFlare's proxy with SSL enabled. When I go to the website though, I get the CloudFlare page Web server is down instead of seeing the express index page. How can I make Express work with CloudFlare's SSL? 回答1: There are two options: You need to alter your app such that it is able to accept HTTPS connections instead of HTTP. You can do this by using the HTTPS library instead of

How to fetch data from mongodb using nodejs, expressjs

让人想犯罪 __ 提交于 2021-01-29 07:50:24
问题 Here is my code file name student.js var mongoose = require('mongoose'); var studentSchema = new mongoose.Schema({ name:{ type: String, required: true }, rollno:{ type: Number, required: true }, grade:{ type: String, required: true }, result:{ type: String, required: true } }); var Student = module.exports = mongoose.model('Student',studentSchema); module.exports.getStudents = function (callback){ Student.find(callback); } **filename app.js** var express = require('express'); var app =

Problem Redirecting after google signin in express react app using passport-google-oauth20

强颜欢笑 提交于 2021-01-29 07:19:32
问题 I have express backend and create-react-app2 as frontend , I am using setupProxy also. Now I have configured the app for google sign in however I am not getting proper redirect to index page after signin. Here is google oauth setup in console.developer.google.com I am using passport google oauth20 for authentication: Here my passport file: const GoogleStrategy = require('passport-google-oauth20').Strategy; const keys = require('./../keys/secret'); const {User} = require('./../models/user');

Why is req.file “undefined” for me when trying to upload a file using multer?

断了今生、忘了曾经 提交于 2021-01-29 06:28:44
问题 I'm trying to allow a user to upload a file using a form, then the image is supposed to be handled using multer in my controller file. For some reason, when I use upload.single('foobar'), it's coming back as "undefined," and screwing up the rest of my application. Specifically, when I run the code, my error handler in the createTour.js file returns an alert that reads "Cannot read property 'imageCover' of undefined". Any help would be appreciated. If helpful, here's the GitHub. Here's the

Why is req.file “undefined” for me when trying to upload a file using multer?

ε祈祈猫儿з 提交于 2021-01-29 06:23:06
问题 I'm trying to allow a user to upload a file using a form, then the image is supposed to be handled using multer in my controller file. For some reason, when I use upload.single('foobar'), it's coming back as "undefined," and screwing up the rest of my application. Specifically, when I run the code, my error handler in the createTour.js file returns an alert that reads "Cannot read property 'imageCover' of undefined". Any help would be appreciated. If helpful, here's the GitHub. Here's the

Node JS Pass variables to pug template's JavaScript and html sections

爱⌒轻易说出口 提交于 2021-01-29 06:21:26
问题 I have the following route and it passes a serires of variables to the pug template. items.js route router.get('/edit/:itemObjectId', async function(req, res, next) { var itemObjectId = req.params.itemObjectId; var equipmentCategoryArr = []; var lifeExpectancyArr = []; var businessUnitResponsibleArr = []; var item = undefined; try { item = await db_item.getItem(itemObjectId); // Where item["result"] is either undefined or a JavaScript Object. E.g. {"createdAt":"2018-11-07T04:07:44.587Z",

Problems installing express using npm.

痞子三分冷 提交于 2021-01-29 05:44:47
问题 Im trying to install express using npm, running this code: npm install express mongoose jade less expresso But i keep getting this error, > make deps/jscoverage/node-jscoverage sh: make: command not found npm ERR! expresso@0.9.2 preinstall: `make deps/jscoverage/node-jscoverage` npm ERR! `sh "-c" "make deps/jscoverage/node-jscoverage"` failed with 127 npm ERR! Failed at the expresso@0.9.2 preinstall script. npm ERR! This is most likely a problem with the expresso package, npm ERR! not with

Firebase hosting cookie behaviours

淺唱寂寞╮ 提交于 2021-01-29 05:41:22
问题 I have couple of questions related to firebase __session cookie and csurf cookies. From this article Manage Cache. Got to know, That cookies are generally stripped from incoming requests. Only the specially-named __session cookie is permitted to pass through to the execution of your app. My question is, when in the cookies there is no __session object and i enter email and password and click submit which triggers the route /sessionLogin, it reads all the cookie objects like below. req.cookies