[英]Using GET with Node.js
我想在我制作的node.js頁面中使用GET獲取變量的值,就像我通常使用PHP(使用$ _GET)所做的那樣。
外觀如下:
http://mygreatpage.herokuapp.com/myThing?X=57
問題是:
如何獲取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.