Localhost:4444/greet isn't working

Input:const express=require(‘express’)
const app=express()

app.get(’/’,(req,res)=>{
res.send(‘Hello Deepti’)
})
app.get(’/greet’,(req,res)=>{
let person=‘guest’;

if(req.query.person){
    person=req.query.person
    req.send('Good evening'+person)
}

})
app.listen(4444,()=>{
console.log(“Server started on http:localhost:4444”)
})

TypeError: req.send is not a function
at /Users/deeptisharma/Desktop/fresh/file1.js:33:13
at Layer.handle [as handle_request] (/Users/deeptisharma/Desktop/fresh/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/deeptisharma/Desktop/fresh/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/Users/deeptisharma/Desktop/fresh/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/deeptisharma/Desktop/fresh/node_modules/express/lib/router/layer.js:95:5)
at /Users/deeptisharma/Desktop/fresh/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/Users/deeptisharma/Desktop/fresh/node_modules/express/lib/router/index.js:335:12)
at next (/Users/deeptisharma/Desktop/fresh/node_modules/express/lib/router/index.js:275:10)
at expressInit (/Users/deeptisharma/Desktop/fresh/node_modules/express/lib/middleware/init.js:40:5)
at Layer.handle [as handle_request] (/Users/deeptisharma/Desktop/fresh/node_modules/express/lib/router/layer.js:95:5)

@sharma.deepti182 change the req.send to res.send, you use the response to send not the request. Change that and it will work

I changed it to res.send but still it isn’t working

@sharma.deepti182 try the following changes

const express = require('express')
const app = express()

app.get('/', (req, res) => {
    res.send("Hello Deepti")
})
app.get('/greet', (req, res) => {
    let person = 'guest'
    if(req.query.person) {
        person = req.query.person
    }
    // res.send outside of if block
    res.send('Good evening' + person)
})
app.listen(4444, ()=>{
    console.log('Server started on http:localhost:4444')
})