Falah Al Fitri
Posted on December 20, 2019
previous post
NodeJS http homepage 20: request url with link menu
Falah Al Fitri ・ Dec 19 '19 ・ 1 min read
#node
#http
#request
#url
DRY is Don't Repeat Yourself, which will be used in link menu.
We will create custom module and export it.
create a file: public/partials/menu.js and write code such as:
var link = `
<ul>
<li><a href="/" >Home</a></li>
<li><a href="/about" >About</a></li>
</ul>
`;
module.exports = link
In index.js, add require menu file
const menu = require('../public/partials/menu');
for each
res.write( `<ul>
<li><a href="/" >Home</a></li>
<li><a href="/about" >About</a></li>
</ul>`
);
replace with
res.write( menu );
💖 💪 🙅 🚩
Falah Al Fitri
Posted on December 20, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.