返回twiml时出现Twilio节点VoiceResponse错误

问题描述

我写了一个twilio函数,它会吐出一些twiml来读出用户当前的天气。但是在代码之外的某个地方,twiml生成失败。

https://gist.github.com/machinshin/331efc2ab31277b98fcb343704d711e9

相关的代码位是第77-79行。

第77行的console.log将以下内容转储到stdin:

    twiml: <?xml version="1.0" encoding="UTF-8"?><Response><Say voice="Polly.Joanna">Hi</Say><Say voice="Polly.Joanna">According to OpenWeatherMap the station nearest Berkeley is currently scattered clouds
          with a temperature ranging from 57.6 Fahrenheit to 60.01 degrees Fahrenheit and a relative humidity of
          43% with an average wind speed of: 5.82 miles per hour</Say></Response>

然后,该框架会转储此操作的XML转换错误,但是据我所知,我所做的一切正确,是否有帮助/想法?

(node:20051) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'XMLDocument'
    |     property 'children' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'XMLDeclaration'
    --- property 'parent' closes the circle
    at JSON.stringify (<anonymous>)
    at stringify (/Users/vat/.twilio-cli/node_modules/express/lib/response.js:1123:12)
    at ServerResponse.json (/Users/vat/.twilio-cli/node_modules/express/lib/response.js:260:14)
    at ServerResponse.send (/Users/vat/.twilio-cli/node_modules/express/lib/response.js:158:21)
    at handleSuccess (/Users/vat/.twilio-cli/node_modules/twilio-run/dist/runtime/route.js:116:9)
    at callback (/Users/vat/.twilio-cli/node_modules/twilio-run/dist/runtime/route.js:164:13)
    at exports.handler (/Users/vat/workspace/machinshin/projects/idwresearch/dist/functions/get_say_weather.protected.js:71:16)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:20051) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection,use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:20051) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)