Just some problems dynamic links

basicily im having problems with making the link to comments dynamic. my goal is that no matter what number i put in it the get will enter my call and give me the id i want the call looks like http://localhost:1234/comments?id=num but im not finding anything that can let my call be dynamic any help is grateful

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>server.js
(async () => {
const db = require("./database");
const users = await db.selectUsers();
console.log(users);
/*const assoc = await db.selectAssoc();
console.log(assoc);*/
const processRequest = require('./processRequest');
const aplicacao = processRequest(1234);
aplicacao.get('/users',function(req,res){
res.write(JSON.stringify(users));
res.end();
});
aplicacao.get('/comments?id=1',function(req,res){
console.log("entered");
res.end();
});
})();
</code>
<code>server.js (async () => { const db = require("./database"); const users = await db.selectUsers(); console.log(users); /*const assoc = await db.selectAssoc(); console.log(assoc);*/ const processRequest = require('./processRequest'); const aplicacao = processRequest(1234); aplicacao.get('/users',function(req,res){ res.write(JSON.stringify(users)); res.end(); }); aplicacao.get('/comments?id=1',function(req,res){ console.log("entered"); res.end(); }); })(); </code>
server.js
    
    (async () => {
        const db = require("./database");
        const users = await db.selectUsers();
        console.log(users);
        /*const assoc = await db.selectAssoc();
        console.log(assoc);*/
        const processRequest = require('./processRequest');
        const aplicacao = processRequest(1234);
        aplicacao.get('/users',function(req,res){
            res.write(JSON.stringify(users));
            res.end();
        });
        aplicacao.get('/comments?id=1',function(req,res){
            console.log("entered");
            res.end();
        });
    })();    
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>processRequest.js
var http = require('http');
var criarProcessRequest = function(porta){
var entrada = {};// Api de entrada
var caminhos = {};// rotas para o pedido
var metodos = ['GET','POST'];// O pedido é enviado com maisculas
metodos.forEach(function(metodo){
caminhos[metodo] = {};
entrada[metodo.toLowerCase()] = function(path,fn){
caminhos[metodo][path] = fn;
};
});
http.createServer(function(req,res){
res.setHeader('Access-Control-Allow-Origin','*');
if(!caminhos[req.method][req.url]){
res.statusCode = 404;
return res.end();
}
caminhos[req.method][req.url](req,res);
}).listen(porta);
return entrada;
};
module.exports = criarProcessRequest;
</code>
<code>processRequest.js var http = require('http'); var criarProcessRequest = function(porta){ var entrada = {};// Api de entrada var caminhos = {};// rotas para o pedido var metodos = ['GET','POST'];// O pedido é enviado com maisculas metodos.forEach(function(metodo){ caminhos[metodo] = {}; entrada[metodo.toLowerCase()] = function(path,fn){ caminhos[metodo][path] = fn; }; }); http.createServer(function(req,res){ res.setHeader('Access-Control-Allow-Origin','*'); if(!caminhos[req.method][req.url]){ res.statusCode = 404; return res.end(); } caminhos[req.method][req.url](req,res); }).listen(porta); return entrada; }; module.exports = criarProcessRequest; </code>
processRequest.js

   var http = require('http'); 
var criarProcessRequest = function(porta){
    var entrada = {};// Api de entrada
    var caminhos = {};// rotas para o pedido
    var metodos = ['GET','POST'];// O pedido é enviado com maisculas    
    metodos.forEach(function(metodo){
        caminhos[metodo] = {};
        entrada[metodo.toLowerCase()] = function(path,fn){
            caminhos[metodo][path] = fn;
        };
    });
    http.createServer(function(req,res){
        res.setHeader('Access-Control-Allow-Origin','*');
        if(!caminhos[req.method][req.url]){
            res.statusCode = 404;
            return res.end();
        }
        caminhos[req.method][req.url](req,res);
    }).listen(porta);
    return entrada;
};
module.exports = criarProcessRequest;

also sorry if the english is bad it isnt my first languege

i have tried special characters like #,$,&,? and have tried researching

New contributor

alex pestana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật