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
Release: 2016-08-08 09:06:33
Original
896 people have browsed it

<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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template