app.send is not a function

technical talkiess
0

 Error:- 

TypeError: app.send is not a function

    Error code:- 

const express = require('express')


const app = express()


const port  = 8080


app.get("/",(req,res)=>{

    app.send("This is my first app");

})


app.listen(port,()=>{

    console.log(`The server is run on the port no ${port}`)

})



Solution code :- 

const express = require('express')


const app = express()


const port  = 8080


// ye wali get method hai

app.get("/",(req,res)=>{

    res.send("This is my first app");

})

app.get("/about",(req,res)=>{

    res.send("This is my first app about page");

})

// niche wlai post method hai

app.post("/about",(req,res)=>{

    res.send("This is my first app about page");

})


app.get("/about",(req,res)=>{

    // apko agar status code send karna hai to aap aise bhej sakte hai

    res.status(200).send("This is my first app about page");

})


app.listen(port,()=>{

    console.log(`The server is run on the port no ${port}`)

})


Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)