gpt4 book ai didi

javascript - 升级后Node.js hapi错误: TypeError: Uncaught error: Object [object Object] has no method 'reply'

转载 作者:太空宇宙 更新时间:2023-11-04 03:10:37 25 4
gpt4 key购买 nike

我们使用 Node.js 中的 hapi 框架开发了我们的服务。最近我们发现有新版本的 hapi 可以通过 npm install 安装。所以我们从1.20升级到2.1.2。现在,对于我发送到服务器的每个 http 请求,我都会收到此错误消息:

Debug: hapi, internal, implementation, error 
TypeError: Uncaught error: Object [object Object] has no method 'reply'

过去,当由于我的代码中存在错误,服务多次尝试回复请求时,我会收到此消息。显然,在第二次尝试中,请求对象的回复功能将丢失。但现在升级到更新版本的hapi后,看来问题应该是我不明白的地方。

最佳答案

自 Hapi 2.0 以来,处理路由的方式发生了一些变化。现在,您必须从函数中的参数获取回复:

server.route({
method: 'GET',
path: '/hello',
handler: function (request, reply) {

reply('hello world');
}
});

我认为这以前已经是可能的,但不是强制性的。

更多信息:https://github.com/spumko/hapi/blob/master/docs/Reference.md#reply-interface

关于javascript - 升级后Node.js hapi错误: TypeError: Uncaught error: Object [object Object] has no method 'reply' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21523523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com