express处理post表单提交请求
引入中间件 body-parase
然后注册使用
这个时候的body对象就能够解析出来了
提取路由模块并调用
对于使用post请求的路由不可以通过地址直接访问,只可以由post表单提交或者其他的post请求来访问
使用promise异步时碰到的问题resolve是返回正确信息的,reject是用来返回错误信息的
(错误信息:
(node:25064) UnhandledPromiseRejectionWarning: [object Uint8Array]
(Use `node --trace-warnings ...` to show where the warning was created)
(node:25064) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or
by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict`
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:25064) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
)
使用find()函数可以找到符合要求的那一项
find()函数的使用
// var stu = [
// {
// name: '旺儿',
// gender: '男',
// age: 20
// },
// {
// name: '狗剩',
// gender: '男',
// age: 20
// },
// {
// name: '小华',
// gender: '男',
// age: 20
// },
// {
// name: '李四',
// gender: '女',
// age: 25
// },
// {
// name: '李四',
// gender: '男',
// age: 26
// }
// ]
var stu=['111','222','333']
var student=stu.find((item,index)=>{
return item=='333'
})
console.log(student)