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
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)
app.put
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