Here I’m going show you how to use static assets in node js and express with the help of importing path library. 
For example let’s say you have public folder in your project and you want to access all files and folder inside this and you to create one static assets for accessing this.
First of you need to import your path library such as
const path = require(‘path‘);
After importing library you can load or define static assets such as
//load static variable
app.use(‘static‘, express.static(path.join(__dirname,’public‘)));

same way you can access public inside folder such as
app.use(‘assets‘, express.static(path.join(__dirname,’public/assets‘)));

News Reporter

Leave a Reply

Your email address will not be published.

*

code