api http get method

 types of middle ware in express 

1) application level middle ware

2) router level middle ware ( router = express.Router();)

3) error handling middle ware

4)build in middle ware

5) third party midelware

const express= require('express');
const app = express();
const PORT=3000;
app.get("/person",(req,res,next) =>
{

}
)
app.listen(PORT,() =>
{
console.log("server on::"+PORT)
}
)


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

}
)

in above

thing

we are uisng express as app

calling get function

when get called we have to send some inputs as req, that api will send some outpits that is res

in next- after succesfull response what have to do





our code is running on sever 3000

k

then when go to person using get method in url 

http://localhost:3000/person

it wil show perosn in dom



testing apis using

post man or arc tools

arc is like extension in crhome

visit below link

https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo/related


after runs the arc extension 

run ur get url using 

http://localhost:3000/person

arci it will show below response








const express= require('express');
const app = express();
const PORT=3000;
app.get("/person",(req,res,next) =>
{
let person={name:"hudere",addr:"vamsi"}
res.send(person);
}
)
app.listen(PORT,() =>
{
console.log("server on::"+PORT)
}
)

write the json in person and print that using get method

for every change u have to run again node second.js

it will pring like below

{"name":"hudere","addr":"vamsi"}




No comments:

Post a Comment

Event listening in react

 How we can listen to som eevents some envents fire like click or automatically user enters into input button , that is event on word type i...