Nodejs Tutorial 3- Query Parameter
Source Code
// lets use query parameter in nodjs
// lets create our first express app first
const express = require(“express”)
// let create app
const app = express()
// create fruits array
fruits =[“mango”,”banana”,”orange”,”graps”]
// lets create our first route
app.get(“/:index”,(req,res)=>{
// to use query parameter, add :index in url
// now we will send the request object/fruit only
res.send(fruits[req.params.index])
})
// listen and serve app on port 8080
app.listen(8080)