[Hapi.js] Using the response object
JS The object Using response
2023-09-14 08:59:20 时间
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') } })
相关文章
- JS+CSS3 360度全景图插件 - Watch3D.js
- JS框架_(JQuery.js)模拟刮奖
- JS框架_(JQuery.js)绚丽的3D星空动画
- JS框架_(JQuery.js)高德地图api
- JS框架_(Popup.js)3D对话框窗口插件
- Js基础知识2-对象、对象属性全解
- js判断是否手机自动跳转移动端
- js模块化的两种规范AMD和CMD
- [Mise] Update a count state value with the x-on event listener directive in Alpine JS
- [WASM Rust] Use the js-sys Crate to Invoke Global APIs Available in Any JavaScript Environment
- [Hapi.js] Using the response object
- 如何通过js文件的名称,反查出这个js文件所在project的artifact id和group id
- js根据内容让select默认选中
- js多线程(用setTimeout实现)
- 【带着canvas去流浪(13)】用Three.js制作简易的MARVEL片头动画(下)#华为云·寻找黑马程序员#
- js 的强制 类型 转换cast, 伪对象?
- 解决运行js代码报错—Warning: To load an ES module, set “type“: “module“ in the package.json or use the .mjs
- js随机飘动的广告图片代码demo效果示例(整理)
- cid unmatched [object Object] at view.umd.min.js:1 TypeError: Invalid attempt to destructure non-ite