[英]Node.js hapi error after upgrading: TypeError: Uncaught error: Object [object Object] has no method 'reply'
We have developed our services using hapi framework in node.js. 我们已经使用node.js中的hapi框架开发了我们的服务。 Recently we found out that there is new version of hapi available for installing via npm install. 最近,我们发现可以通过npm install安装新版本的hapi。 So we upgraded from 1.20 to 2.1.2. 所以我们从1.20升级到2.1.2。 now for every http request that I send to the server I get this error message: 现在,对于我发送到服务器的每个http请求,我都会收到以下错误消息:
Debug: hapi, internal, implementation, error
TypeError: Uncaught error: Object [object Object] has no method 'reply'
I used to get this message when, as a result of a bug in my code, the service was trying to reply to a request more than once. 由于代码中的错误,我曾经收到此消息,因为该服务试图多次答复请求。 Apparently, in the second try the reply function of the request object would be missing. 显然,在第二次尝试中,请求对象的回复功能将丢失。 But now after upgrading to newer version of hapi, it seems that the problem should be something that I don't understand. 但是现在在升级到较新版本的hapi之后,看来问题应该是我不了解的。
Since Hapi 2.0, the way you handle a route has changed a bit. 自Hapi 2.0起,您处理路线的方式已发生了一些变化。 Now, you have to grab a reply
from the parameters in your function: 现在,您必须从函数中的参数中获取reply
:
server.route({
method: 'GET',
path: '/hello',
handler: function (request, reply) {
reply('hello world');
}
});
I think it was already possible before but it wasn't mandatory. 我认为以前已经可以,但不是强制性的。
More informations: https://github.com/spumko/hapi/blob/master/docs/Reference.md#reply-interface 更多信息: https : //github.com/spumko/hapi/blob/master/docs/Reference.md#reply-interface
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.