node/express - missing ) after argument list [closed]

我们两清 提交于 2021-02-11 08:17:07

问题


new to node...

const express = require('express');
const bodyParser= require('body-parser');
const MongoClient = require('mongodb').MongoClient;
const app = express();

app.use(bodyParser.urlencoded({extended: true}));
app.set('view engine', 'ejs');

module.exports = function PeopleController() {

function process(req, res, next) {
    var baseURL = '/people';

    app.get(baseURL + '/?', (req, res) => {
      console.log('people get');
    });

    app.post((baseURL + '/people', (req, res) => {
      console.log('people post');
    });
  }
}

SyntaxError: missing ) after argument list

[nodemon] app crashed - waiting for file changes before starting...


回答1:


You have an unnecessary parenthesis in

app.post((baseURL + '/people', ...);

Replace that with

app.post(baseURL + '/people', ...);

or enclose the first parameter with a closing parenthesis.

app.post((baseURL + '/people'), ...);


来源:https://stackoverflow.com/questions/42288361/node-express-missing-after-argument-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!