express json |node js tutorials

 


express.js

app.get
app.post
app.put
app.delete
app.all
app.use
app.listen

for any url it shows not found
app.all('*',(req,res)=>{res.status(404).send('<h1> resource not found</h1>')})




json basics

https://react-project-2-tours.netlify.app/

array of jsons


https://expressjs.com/en/5x/api.html

res.json([{}])


import json
const {products} =require('./data')
res.json(products)


const newProducts = products.map()
const newProducts = products.map(()=>{})
const newProducts = products.map((product)=>{
const {id,image,name} = product;
return {id,name,image}
})
res.json (newProducts)
it will filter the required keys

by product id


long lenth url




url
query=somethos&tags=comment






app.put






app.delete


router


api.js
 const route r = express.Router();
router.post
router.get

module.exports = router;

in app.js
const people = requoer('./routes/people')

app.use('api/people',people)


postman -api/people -> get


auth.js


 









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...