これが私のコードです:
var express = require('express');
var app = express();
app.get('/:name', function(req,res){
res.setHeader('Content-Type','text/html');
res.send('<form action="/" method="POST"><input type="text" name="self"/><input type="submit"/></form>');
});
app.post('/',function(req,res){
res.send(req.body.self);
});
app.listen(8080);
localhost:8080/examplenameと呼びます
入力の中に何かを書いて、送信ボタンをクリックします。localhost:8080に移動しますが、ノードは次のようなエラーを返します。
TypeError: Cannot read property 'self' of undefined
at /home/yusuf/Masaüstü/node/ue.js:10:19
at callbacks (/home/yusuf/Masaüstü/node/node_modules/express/lib/router/index.js:160:37)
at param (/home/yusuf/Masaüstü/node/node_modules/express/lib/router/index.js:134:11)
at pass (/home/yusuf/Masaüstü/node/node_modules/express/lib/router/index.js:141:5)
at Router._dispatch (/home/yusuf/Masaüstü/node/node_modules/express/lib/router/index.js:169:4)
at Object.router [as handle] (/home/yusuf/Masaüstü/node/node_modules/express/lib/router/index.js:32:10)
at next (/home/yusuf/Masaüstü/node/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Object.expressInit [as handle] (/home/yusuf/Masaüstü/node/node_modules/express/lib/middleware.js:31:5)
at next (/home/yusuf/Masaüstü/node/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Object.query [as handle] (/home/yusuf/Masaüstü/node/node_modules/express/node_modules/connect/lib/middleware/query.js:44:5)