I have this code:
server.get("/chat", (req, res) => {
let query = url.parse(req.url, true).query;
console.log(query.channel);
let rueckgabe = {
channel: query.channel
};
res.sendFile('chat.html', { root: path.join(__dirname, 'public/') });
res.send(JSON.stringify(rueckgabe));
});
I can't use both res.sendFile
and res.send
. How can I use both in server.get
?
Different approach
If I try something like this it executes only the first code.
server.get("/chat", (req, res) => {
let query = url.parse(req.url, true).query;
console.log(query.channel);
let rueckgabe = {
channel: query.channel
};
res.send(JSON.stringify(rueckgabe));
});
server.get("/chat", (req, res) => {
res.sendFile('chat.html', { root: path.join(__dirname, 'public/') });
});
So the result would be getting the rueckgabe
but without html
page.