express

Iterate over javascript object in pug

淺唱寂寞╮ 提交于 2021-02-08 02:12:35
问题 I've seen a few of these questions but the answers never seem to be clear cut. I need to iterate through a javascript object in my pug view. First time using pug, so I may be missing something obvious. Controller: app.get('/search/:keyword', (req, res) => { scraper .searchDictionary(req.params.keyword) .then(words => { res.render('result', console.log(words)) }); }) Here is the actual function that makes the object: function searchDictionary(searchTerm){ const url = `https://www.dictionary

Confusion regarding express server and nodejs http server

谁说胖子不能爱 提交于 2021-02-08 02:00:36
问题 I am learning redis and in the docs they have the following server setup: var app = require('express')(); var server = require('http').Server(app); var io = require('socket.io')(server); server.listen(80); app.get('/', function (req, res) { res.sendfile(__dirname + '/index.html'); }); io.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event', function (data) { console.log(data); }); }); As you can see they are creating the express server on

Confusion regarding express server and nodejs http server

。_饼干妹妹 提交于 2021-02-08 02:00:20
问题 I am learning redis and in the docs they have the following server setup: var app = require('express')(); var server = require('http').Server(app); var io = require('socket.io')(server); server.listen(80); app.get('/', function (req, res) { res.sendfile(__dirname + '/index.html'); }); io.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event', function (data) { console.log(data); }); }); As you can see they are creating the express server on

Express & EJS - layout.ejs not used

谁说胖子不能爱 提交于 2021-02-07 20:23:43
问题 Im trying out EJS as a view engine with Express. It seems that my layout.ejs is not used. I have two views index.ejs and layout.ejs both in my 'views' folder. It seems that index.js is rendered but layout.ejs is not. The layout.ejs file should be including a CSS file but when the page is rendered in the browser this is not there. Any test test text that I place in the layout.ejs file is not output with the response. Am I missing an additional configuration step? Thanks! My server.js code: var

Error Message from MongoDB “Operation `disneys.insertOne()` buffering timed out after 10000ms”"

╄→гoц情女王★ 提交于 2021-02-07 19:36:19
问题 I'm currently creating a new API with MongoDB and Express, and I'm currently having this issue "Operation disneys.insertOne() buffering timed out after 10000ms." I'm currently using route.rest to test my API. However, I don't know what I'm currently doing wrong, could someone take a look at my Github Repository ? This is the way that I setup my API calls: const express = require("express"); const router = express.Router(); const Disney = require("../models/disneyCharacter"); // Getting all

Error Message from MongoDB “Operation `disneys.insertOne()` buffering timed out after 10000ms”"

时光总嘲笑我的痴心妄想 提交于 2021-02-07 19:36:00
问题 I'm currently creating a new API with MongoDB and Express, and I'm currently having this issue "Operation disneys.insertOne() buffering timed out after 10000ms." I'm currently using route.rest to test my API. However, I don't know what I'm currently doing wrong, could someone take a look at my Github Repository ? This is the way that I setup my API calls: const express = require("express"); const router = express.Router(); const Disney = require("../models/disneyCharacter"); // Getting all

JWT UnauthorizedError: No authorization token was found (GET request with cookie)

百般思念 提交于 2021-02-07 18:16:24
问题 I have a strange problem, or maybe I don't understand how JWT works in Express context. var express = require('express') var app = express(); var expressJWT = require('express-jwt'); var jwt = require('jsonwebtoken'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var unless = require('express-unless'); app.set('secret', 'some secret'); app.use(cookieParser()); app.use(bodyParser.urlencoded({ extended: false })); app.use("/", expressJWT({secret:app.get(

async await not working with callback node (without promise)

六眼飞鱼酱① 提交于 2021-02-07 18:09:41
问题 hello guys i got confused why this not working here is my connection js file function getConnection(callback) { initPool() mysql_pool.getConnection((err, conn) => { if (err) { return callback(err); } return callback(err, conn); }); } function query(queryString, callback) { getConnection((err, connection2) => { if (connection2 != undefined) { if (err) { connection2.destroy(); return callback(createDataResponseObject(err, null)) } connection2.query(queryString, function (err, rows) {

async await not working with callback node (without promise)

余生长醉 提交于 2021-02-07 18:09:27
问题 hello guys i got confused why this not working here is my connection js file function getConnection(callback) { initPool() mysql_pool.getConnection((err, conn) => { if (err) { return callback(err); } return callback(err, conn); }); } function query(queryString, callback) { getConnection((err, connection2) => { if (connection2 != undefined) { if (err) { connection2.destroy(); return callback(createDataResponseObject(err, null)) } connection2.query(queryString, function (err, rows) {

Expressjs passport-local can't logout

≡放荡痞女 提交于 2021-02-07 14:25:22
问题 I copy pasted the app passport-local on my app, The fun is I can log in users, but I can't make them logout, app.get('/logout', function(req, res){ req.logout(); res.redirect('/'); }); this is not doing nothing, nothing on the logfiles, and I I have its a link to /logout this is the main route examples app.get('/page1', function(req, res){ res.render('page1', {user: req.user}); }); app.get('*', function(req,res){ res.render('root', {user: req.user}); }); Why the logout its not working ????