ExpressJS is a JavaScript framework that allows you to make advanced api for your web app
first you need to make a my-projectfolder
Then open terminal and type this code
Then you need to install express, you can install express by this code
After this code you need to replace scripts in your package.json file with this code
“start”:”node app.js”
}
Then make app.js file
and pus this code inside your app.js file
const app = express()
// /api route
app.get(‘/api’,(req, res) => {
res.send(‘hello world!’) // this will return hello world! When you go to https://localhost:3000/api
})
// make app listen on port 3000
app.listen(3000, (req, res) => {
console.log(“app listening on https://localhost:3000”)
})
then run
And navigate to https://localhost/3000/api
And you’ll see ‘hello world!’
Text
That’s it.