Home >Backend Development >PHP Tutorial >javascript - After referencing connect in node, using its own middleware will always report an error

javascript - After referencing connect in node, using its own middleware will always report an error

WBOY
WBOYOriginal
2016-08-08 09:06:33880browse

<code>    var connect = require('connect');
    var app = connect()
        .use(connect.cookieParser())
        .use(function(req,res){
        console.log(req.cookie);
        console.log(req.signedCookies);
    }).listen(3000);</code>

Tips: connect.cookieParser is not a function;
It will also prompt when using bodyParser.
It is said online that it is separated from connect. You need to npm install cookieParser again.
Is bodyParser also needed? All the intermediate Do you need all the pieces?

Reply content:

<code>    var connect = require('connect');
    var app = connect()
        .use(connect.cookieParser())
        .use(function(req,res){
        console.log(req.cookie);
        console.log(req.signedCookies);
    }).listen(3000);</code>

Tips: connect.cookieParser is not a function;
It will also prompt when using bodyParser.
It is said online that it is separated from connect. You need to npm install cookieParser again.
Is bodyParser also needed? All the intermediate Do you need all the pieces?

Middleware such as cookieParser has been separated from connect and can be used independently without loading connect

next Why are there no parameters?

Already solved
javascript - After referencing connect in node, using its own middleware will always report an error

javascript - After referencing connect in node, using its own middleware will always report an error

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn