不能得到hapi的回复标题工作

我试图让智威汤逊工作,我正在发送令牌回客户的困难。 我试图发送它在头像例子:

例如: jwt

res.writeHead(200, { 'content-type': 'text/html', 'authorization': token}); 

我正在尝试类似于:

 reply('Here is token').header({ 'content-type': 'text/html', 'authorization': token}).code(200); 

但是我得到一个错误

TypeError:未捕获错误:key.toLowerCase不是函数

不知何故,我找不到如何做到这一点的例子。 我想将令牌发送回头部的“客户端应用程序”,但无法find与hapi做的方式。 任何人有任何线索?

链接的语法是这样的

 return reply('Here is token') .type('text/html') .header('X-authorization', token) .code(200); 

通常情况下,人们会将响应正文中的令牌发送回客户端以及一些用于前端方便的用户信息,因此您的回复可能看起来更像这样

 const authenticatedUser = { id: 'testuser', firstName: 'Simon', lastName: 'Prince', token: 'bearer supersecretjwttokenhere' }; return reply(authenticatedUser); 

您的客户端应用程序将获得该JSON响应,获取令牌,将其存储在本地存储中,并使用响应中的用户信息更新UI。