我对express框架还比较陌生。在express API参考文档中找不到application.post()方法的文档。能否有人提供一些可以放入该函数的所有可能参数的示例?我已经阅读了几个网站,其中有以下示例,第一个参数是什么意思?
I know the second parameter is the callback function, but what exactly do we put in the first parameter?
app.post('/', function(req, res){
Also, let's say we want the users to post(send data to our server) ID numbers with a certain format([{id:134123, url:www.qwer.com},{id:131211,url:www.asdf.com}]). We then want to extract the ID's and retrieves the data with those ID's from somewhere in our server. How would we write the app.post method that allows us to manipulate the input of an array of objects, so that we only use those object's ID(key) to retrieve the necessary info regardless of other keys in the objects. Given the description of the task, do we have to use app.get() method? If so, how would we write the app.get() function?
express.bodyParser()
返回一些带有签名function(req, res, next)
的函数,并在将json解析为req.body
对象后内部调用next()
。然后,Express将请求传递到中间件链的下一个环节,即app.post('/yourPath', ...)
的第三个参数,这是Peter编写的函数。 - Platoapp.get
!感谢你的app.VERB
评论。 - zastrowm