我是Node.js的初学者,正在研究以下示例代码,我不理解为什么为什么要两次使用[app.use(bodyParser.json());],#的目的是什么? 1和#2?谢谢
var express = require('express');
var http = require('http');
var path = require('path');
var fs = require('fs');
var mime = require('mime');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var cfenv = require('cfenv');
var vcapServices = require('vcap_services');
var appEnv = cfenv.getAppEnv();
var app = express();
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json()); // #1
app.set('appName', 'watsonDemo');
app.set('port', process.env.PORT || 6003);
app.set('views', path.join(__dirname + '/HTML'));
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'ejs');
app.use(express.static(__dirname + '/HTML'));
app.use(bodyParser.json()); // #2
app.use('/', require("./controller/restapi/router"));