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)
Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: