express-4

Express 4 + pm2 watch not working

China☆狼群 提交于 2019-11-27 04:14:37
问题 I'm running pm2 with this: pm2 start bin/www --watch ../ Problem is that when I update app.js in the root folder, it doesn't seem to be autorestarting node. Any ideas? 回答1: Figured out a solution: //processes.json: { "apps" : [{ "name" : "someExpress4App", "script" : "bin/www", "watch" : "../", "log_date_format" : "YYYY-MM-DD HH:mm Z", }] } Put that on the root of your project, then run your pm2 as so: pm2 start processes.json 来源: https://stackoverflow.com/questions/27882759/express-4-pm2

How to handle FormData from express 4

不羁的心 提交于 2019-11-26 19:42:12
问题 I tried sending some form data to my node server but req.body has none of my form fields the node side var express = require('express') var app = express() var path = require('path') var bodyParser = require('body-parser') app.use(bodyParser.urlencoded({ extended: true })); app.get('/', function (req, res) { res.sendFile('index.html') }) app.post('/sendmail', function (req, res) { const formData = req.body.formData this is what I'm sending from the browser fetch('/send', { method: 'POST',