1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

node.jsでget,postのフォーム通信(express)

Posted at

var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var ejs = require('ejs');

app.engine('ejs', ejs.renderFile);
app.use(bodyParser.urlencoded({
extended:true
}));

app.get('/', (req, res) => {
console.log('--get req--');
console.log('name:' + req.query.name);
console.log('age:' + req.query.age);
res.render('temp.ejs', {});
});

app.post('/', (req, res) => {
console.log('--post req--');
console.log('name:' + req.body.name);
console.log('age:' + req.body.age);
res.render('temp.ejs', {});
});

var server = app.listen(1234, () => console.log('wakeUp'));

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?