[英]Using GET with Node.js
I want to use GET, to get the value of a variable, inside a node.js page I made, as I would normally do (with $_GET) using PHP. 我想在我制作的node.js页面中使用GET获取变量的值,就像我通常使用PHP(使用$ _GET)所做的那样。
Here is how it looks: 外观如下:
http://mygreatpage.herokuapp.com/myThing?X=57
The question is: 问题是:
How do I get the value of X (57 in the example above) inside my index.js file? 如何获取index.js文件中X的值(在上面的示例中为57)?
var app = require('express')();
var http = require('http').Server(app);
app.get('/myThing',function(req,res)
console.log(req.query.X);
res.send(req.query.X);
}
);
app.listen(3000);
console.log("server start");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.