node.js request and response related

һ ȡֵ post ��getȡֵ

1��

GET /test?name=fred&tel=0926xxx572


app.get('/test', function(req, res) {

    console.log(req.query.name);

    console.log(req.query.tel);

});


2��POST

<form action='/test' method='post'> 

    <input type='text' name='name' value='fred'> 

    <input type='text' name='tel' value='0926xxx572'> 

    <input type='submit' value='Submit'> 

</form>

app.post('/test', function(req, res) {

    console.log(req.query.id);

    console.log(req.body.name);

    console.log(req.body.tel);

});


3�� HTTP Routing :

GET /hello/fred/0926xxx572

app.get('/hello/:name/:tel', function(req, res) {

    console.log(req.params.name);

    console.log(req.params.tel);

});

���

https://cnodejs.org/topic/50a333d7637ffa4155c62ddb


你可能感兴趣的:(node.js request and response related)