【发布时间】:2020-11-10 20:07:04
【问题描述】:
我编写了一个 twilio 函数,它会吐出一些 twiml 来读出用户当前的天气。然而,在我的代码之外的某个地方,twiml 生成失败了。
https://gist.github.com/machinshin/331efc2ab31277b98fcb343704d711e9
相关的代码位是第 77-79 行。
第 77 行的 console.log 将以下内容转储到标准输入:
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.
【问题讨论】:
标签: twilio twilio-api twilio-twiml