简体   繁体   English

升级后的Node.js hapi错误:TypeError:未捕获的错误:Object [对象Object]没有方法'reply'

[英]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.

相关问题 奇怪的 node.js 错误:TypeError: Object #<Object> 没有方法“开” - Strange node.js error: TypeError: Object #<Object> has no method 'on' Node.js对象[object Object]没有方法错误 - Node.js Object [object Object] has no method error 在Node.js服务器内发出异步请求错误:“ TypeError:对象# <Object> 没有方法“ _implicitHeader”” - Making asynchronous requests within a Node.js server error:“TypeError: Object #<Object> has no method '_implicitHeader'” 未捕获的TypeError:对象# <error> 没有方法“呼叫” - Uncaught TypeError: Object #<error> has no method 'call' 未捕获的TypeError:对象# <error> 没有办法 - Uncaught TypeError: Object #<error> has no method JavaScript错误:未捕获的TypeError:对象[object Object]没有方法&#39;src&#39; - Javascript error: Uncaught TypeError: Object [object Object] has no method 'src' JQtouch错误:未捕获的TypeError:对象[object Object]没有方法&#39;live&#39; - JQtouch error : Uncaught TypeError: Object [object Object] has no method 'live' Node.js Socket.IO“未捕获的TypeError:对象# <Server> 没有方法“关闭”” - Node.js Socket.IO “Uncaught TypeError: Object #<Server> has no method 'close'” 未捕获的TypeError:Object# <Object> 没有方法&#39;apply&#39;错误 - Uncaught TypeError: Object #<Object> has no method 'apply' error 奇怪的错误:未捕获的TypeError:对象[object HTMLElement]没有方法&#39;getAttribute&#39; - Weird error: Uncaught TypeError: Object [object HTMLElement] has no method 'getAttribute'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM