[Hapi.js] Using the response object
JS The object Using response
2023-09-14 09:00:54 时间
When you use reply method:
let resp = reply('hello world')
It actually return an response object.
By using response object, you can modiy the response's status code, header, cookie, type and so on...
server.route({ method: 'GET', path: '/', handler: function(request, reply) { let resp = reply('hello world') resp.code(418) // set status code to 418 resp.type('text/plain') // set type to text/plain resp.header('hello', 'world') // set header to hello: world resp.state('hello', 'world') // set cookie to hello=world }
response object is chainable:
server.route({ method: 'GET', path: '/', handler: function(req, reply){ reply('hello world') .code(418) .type('text/plain') .header('hello', 'world') -state('hello', 'world') } })
相关文章
- html js 全局 变量,JS定义全局变量
- HTML+CSS+JS网页设计期末课程大作业 web前端开发技术 web课程设计 网页规划与设计
- php 中js跳转页面跳转页面,js跳转代码_PHP页面跳转 Js页面跳转代码[通俗易懂]
- 用JS获取地址栏url参数的方法_js的url是啥
- 【说站】js中this的使用场景
- 【说站】js中字符串位置的搜索方法
- Vue.js – 引入外部 JS 文件
- 高频js手写题之实现数组扁平化、深拷贝、总线模式_2023-02-23
- ORA-28074: The “string” field of the redaction parameters is not valid. ORACLE 报错 故障修复 远程处理
- ORA-31692: The following SQL statement failed trying to insert a row into the Master table: string ORACLE 报错 故障修复 远程处理
- ORA-13605: The specified task or object string does not exist for the current user. ORACLE 报错 故障修复 远程处理
- ORA-13614: The template string is not compatible with the current advisor. ORACLE 报错 故障修复 远程处理
- ORA-13621: The task_or object string is marked as a template and cannot perform the requested operation. ORACLE 报错 故障修复 远程处理
- the cloudTaking Oracle to the Cloud: The Evolution of Database Systems(oracleisin)
- JS技术连接Oracle数据库实现数据交互(js连接oracle实例)
- JS将文件传输至MySQL数据库(.js传文件至mysql)
- js弹簧效果代码
- js动态添加onload、onresize、onscroll事件(另类方法)
- 解析js如何获取当前url中的参数值并复制给input
- js页面跳转的问题(跳转到父页面、最外层页面、本页面)
- Js获取数组最大和最小值示例代码
- js使用DOM设置单选按钮、复选框及下拉菜单的方法