在我的Hapi.js服务器上,如果帐户没有权限访问API端点,我想发送一个特定的消息。我现在拥有的Boom消息如下:
return reply(Boom.unauthorized("unauthorized access to this API."));
这将返回一个类似于以下的信息提示框:
{
"statusCode": 401,
"error": "Unauthorized",
"message": "unauthorized access to this API."
}
我想要将其定制,使其外观更像这样:
{
"success": false,
"message": "unauthorized access to this API.",
"csrf-decorator": "",
"redirect": ""
}
我们是否可以自定义Boom错误信息?
谢谢!