Please take a look at the following code, why does the page always appear undefined

  node.js, question
var http = require ('http');
var qs = require('querystring');
http.createServer(function (req,res) {
    if ('/'==req.url) {
        res.writeHead(200,{'Content-Type':'text/html'});
        res.end([
            '<form action="/url" method="POST">',
                '<h1>My form</h1>',
                '<fieldset>',
                '<label>Personal information</label>',
                '<p>What is your name ?</p>',
                '<input type="text" name="name">',
                '<p><button>Submit</button></p>',
            '</form>'
        ].join(' '));
    } else if ('/url'==req.url && 'POST'==req.method) {
        //创建一个字符串吸收数据块
        var body = ' ';
        req.on('data', function (chunk) {
            body加=chunk;
        });
        //监听end事件
        req.on('end', function () {
            res.writeHead(200,{'Content-Type' : 'text/html'});
            res.end('<p>Your name is <b>' 加qs.parse(body).name加'</b></p>');
        });
    } else {
        res.writeHead(404);
        res.end('Not Found');
    }
}).listen(3000);

图片描述
图片描述

The reason is:

//Create a string absorption data block
 var body = ' ';  //When initializing, do not have spaces in it

One more space,queryStringThere will be problems when parsing, thusqs.parse(body).nameonundefinedHere we go.