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