Hello I'm learning to use Nodejs on my own, and I'm struggling on something that looks really really simple but with fatigue I can't seem to make it work even with an embarassing number of google searches.(您好,我正在学习自己使用Node.js的方法,我正在努力尝试看起来非常简单的方法,但是由于疲劳,即使使用了大量的Google搜索,我似乎也无法使其正常工作。)
I tried to unstuck myself but I need help.(我试图解开自己,但我需要帮助。)
Here is part of my code.(这是我的代码的一部分。)
I use EJS for the template.(我使用EJS作为模板。)
var express = require('express');
var request = require('request');
var bodyParser = require("body-parser");
const querystring = require('querystring');
const url = require('url');
var app = express();
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: true }));
const fetch = require("node-fetch");
// URL par défaut
app.get('/', function (req, res) {
res.render('index');
});
//------------------------------------------------------
// Client
app.get('/client', function (req, res) {
res.render('client');
});
// Edit Client
app.get('/Eclient, function (req, res) {
res.render('eclient', {query : req.query});
});
// set port
app.listen(3001, function () {
console.log('Node app is running on port 3001');
});
module.exports = app;
On my Client page there is a form that is sending to Eclient a parameter called pIDC, with an URL like this : http://localhost:3001/Eclient?pIDC=1
I want to get the value of pIDC on my EJS page with something like <%= req.query.pIDC%>;
(在“我的客户”页面上,有一种形式正在向Eclient发送一个名为pIDC的参数,该参数具有如下URL: http://localhost:3001/Eclient?pIDC=1
我想通过以下方法在我的EJS页面上获取pIDC的值:类似于<%= req.query.pIDC%>;
)
so I can in a second time query the data of the client from my API.(因此,我可以第二次从我的API查询客户端的数据。) But I can't seem to make it work, everytime the data is undefined.(但是,每次数据未定义时,我似乎都无法正常工作。)
I'm sure it's trivial, but I can't seem to make it work even with all the searches I did.(我敢肯定它是微不足道的,但是即使我进行了所有搜索,我也似乎无法使其正常工作。)
What am I missing ?(我想念什么?)
ask by Sareth translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…