This post is about how to catch and deal with parameter sent by post method from client. First of all, you need to download and set up a middleware to achieve the goal.
The middleware's name is body-parser. You install body parser.
$ npm install body-parser --save
Then, set up in your app.js
// add middleware
app.use(bodyParser.json()); //suport json encoded bodies
app.use(bodyParser.urlencoded({extended:true}));//support encoded bodies
Then, play with it like one below.
/*Ajax post*/
router.post('/postparams',function(req, res){
var receiver_acct = req.body.receiver_acct;
var memo = req.body.memo;
res.send(receiver_acct + " "+ memo);
});
module.exports = router;
This will work.
'' 카테고리의 다른 글
EOS Smart Contract deploy 하기. (0) | 2018.11.19 |
---|---|
EOS에서 RAM, CPU, Brandwidth 그리고 Network Brandwidth란 (0) | 2018.11.07 |
In NODE JS, Express 4 how to catch post method parameter (0) | 2018.11.03 |
기존 account로 새 account 만들기 (0) | 2018.10.18 |
EOS Dapp 개발 Chapter1-2: EOSIO/EOS image 다운로드 및 설치 (0) | 2018.10.11 |
EOS Dapp 개발 Chapter1-1: Docker 설치하기 (0) | 2018.10.11 |