You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i want to ask something, how to get the post data? I try post data but it always show error
TypeError: Cannot read property 'user' of undefined at Object.handle (/home/dikdik/nodeapp/router/main.js:11:26) at next_layer (/home/dikdik/nodeapp/node_modules/express/lib/router/route.js:103:13) at Route.dispatch (/home/dikdik/nodeapp/node_modules/express/lib/router/route.js:107:5) at c (/home/dikdik/nodeapp/node_modules/express/lib/router/index.js:195:24) at Function.proto.process_params (/home/dikdik/nodeapp/node_modules/express/lib/router/index.js:251:12) at next (/home/dikdik/nodeapp/node_modules/express/lib/router/index.js:189:19) at next (/home/dikdik/nodeapp/node_modules/express/lib/router/index.js:166:38) at Layer.expressInit as handle at trim_prefix (/home/dikdik/nodeapp/node_modules/express/lib/router/index.js:226:17) at c (/home/dikdik/nodeapp/node_modules/express/lib/router/index.js:198:9)
i try googling it, but still didn't get any result.
this is my source code.
//server.js
var express=require('express');
var bodyParser = require('body-parser');
var http = require('http');
var app=express();
require('./router/main')(app);
app.set('views',__dirname+'/views');
app.set('view engine','ejs');
app.engine('html',require('ejs').renderFile);
app.use(bodyParser.text());
app.use(bodyParser.urlencoded({extended:true}));
var server=app.listen(3000,function(){
console.log("Started listen port 3000");
});
//main.js
module.exports=function(app){
app.get('/',function(req,res){
var body = '';
var url = "http://localhost:3000/";
res.render('index.html',{title:'Apa atuh',content:'Ini content',url:url});
});
app.post('/about',function(req,res){
var username = req.body.user;
var password = req.body.pass;
res.render('about.html',{user:username,pass:password});
});
}
i start to learn again nodejs, but i already forget about it, can you help me?
The text was updated successfully, but these errors were encountered:
hello Mr Han and Mr Jollen, how are you?
i want to ask something, how to get the post data? I try post data but it always show error
TypeError: Cannot read property 'user' of undefined at Object.handle (/home/dikdik/nodeapp/router/main.js:11:26) at next_layer (/home/dikdik/nodeapp/node_modules/express/lib/router/route.js:103:13) at Route.dispatch (/home/dikdik/nodeapp/node_modules/express/lib/router/route.js:107:5) at c (/home/dikdik/nodeapp/node_modules/express/lib/router/index.js:195:24) at Function.proto.process_params (/home/dikdik/nodeapp/node_modules/express/lib/router/index.js:251:12) at next (/home/dikdik/nodeapp/node_modules/express/lib/router/index.js:189:19) at next (/home/dikdik/nodeapp/node_modules/express/lib/router/index.js:166:38) at Layer.expressInit as handle at trim_prefix (/home/dikdik/nodeapp/node_modules/express/lib/router/index.js:226:17) at c (/home/dikdik/nodeapp/node_modules/express/lib/router/index.js:198:9)
i try googling it, but still didn't get any result.
this is my source code.
//server.js
var express=require('express');
var bodyParser = require('body-parser');
var http = require('http');
var app=express();
require('./router/main')(app);
app.set('views',__dirname+'/views');
app.set('view engine','ejs');
app.engine('html',require('ejs').renderFile);
app.use(bodyParser.text());
app.use(bodyParser.urlencoded({extended:true}));
var server=app.listen(3000,function(){
console.log("Started listen port 3000");
});
//main.js
module.exports=function(app){
}
i start to learn again nodejs, but i already forget about it, can you help me?
The text was updated successfully, but these errors were encountered: