【发布时间】:2019-01-23 23:57:03
【问题描述】:
我正在 azure (v3) 上开发一个 Web 应用程序机器人,并且我正在使用异步方法,但我似乎无法解决 SyntaxError: Unexpected token function 的问题。
我尝试将我的 nodeJS 从 6.9.4 更新到 8.9,但没有成功。我还运行了 npm i -g azure-functions-core-tools@core 但仍然没有。
class OAuthHelpers {
/**
* Enable the user to schedule meeting and send an email attachment via the bot.
* @param {TurnContext} turnContext
* @param {TokenResponse} tokenResponse
* @param {*} emailAddress The email address of the recipient
*/
async function createevent(turnContext, tokenResponse, emailAddress) {
if (!turnContext) {
throw new Error('OAuthHelpers.createevent(): `turnContext` cannot be undefined.');
}
if (!tokenResponse) {
throw new Error('OAuthHelpers.createevent(): `tokenResponse` cannot be undefined.');
}
var client = new SimpleGraphClient(tokenResponse.token);
// Calls the Graph API with the subject and content message...
await client.createevent(
emailAddress,
`Lunch`,
`I will be taking everyone to lunch as a reward for your hardwork.`
);
// Success message...
await turnContext.sendActivity(`Success! I have scheduled a meeting with you and ${ emailAddress } have created an event on each of their calendars.`);
}
我希望机器人正常运行,但它不能,因为 azure 由于某种原因无法检测到异步功能。任何帮助表示赞赏
【问题讨论】:
-
你是否成功安装了node 8.x版本?还是升级失败了?如果是这样,请考虑使用 nvm 节点版本管理器,它允许您以最简单的方式在版本之间切换。
-
我进入我的应用程序设置并将其从 8.9 更改为运行 node -v 时在终端中显示 8.9
-
你能显示更多部分代码吗,我不确定上面的行是否真的有问题
-
我添加了更多代码以便您更好地理解
-
您提到您使用的是 v3 SDK,但“turnContext”是 v4 SDK 对象。 v3 使用“会话”。您能否说明您使用的是哪个版本的 SDK?
标签: node.js azure botframework azure-language-understanding azure-function-async