Should id be placed in the path of API or in request?

I see an example when he deletes the id is put in the url, as follows

router.delete("/:id",function(req,res){})

but you do put it in req.body when you update it, as follows

router.update("/",function(req,res){
    //req.body._id
})

Why is this? Are there any specific rules?
where should I put id if I want to use get and post?

Feb.28,2021
For the rules in

routing, please refer to the official document http://www.expressjs.com.cn/4.
. Since it is a route, the rules can only be found in


in url.

your first example: router.delete ('/: id',function (req,res) {}) is in line with REST interface specification

second example: it is written by an individual, according to personal habits

there is no special rule for this. If you have a team request, you have to write

as required.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e89b5f-f7b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e89b5f-f7b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?