const express = require("express")
const app = express()
app.post("/create1",(req,resp)=>{
console.log("server started")
resp.send("done")
})
app.listen(3000)
I should get a
send
on the
https:// localhost:3000/create,
i tried changing port number, but am getting same error
CodePudding user response:
This should go ahead and fix your problem.
app.get("/create",(req, res)=>{
console.log("server started");
res.send("done");
})
CodePudding user response:
There are 3 reasons for not getting the response.
- You named the route as create1 but you are hitting the API as create.
- You used https. It will be http
- You have created a POST (app.post(...) route but you are calling the route in GET method. So, use Postman tool, change the method to POST and hit the API.
So, The API would be : http://localhost:3000/create1
(Hit it in POST method from Postman)