0

我正在尝试在 Wit.ai 中的 Node.js 中定义多个动作编码,但出现错误 -

“[错误] [相反]错误:TypeError:无法读取未定义的属性'替换'”

有谁知道我为什么得到这个,以及定义多个动作的正确方法是什么?

谢谢!

const actions = {
    say(sessionId, context, message, cb) {
        console.log(message);
        cb();
    },
    merge(sessionId, context, entities, message, cb) {
        // Retrieve the location entity and store it into a context field
        `enter code here`
        const loc = firstEntityValue(entities, 'location');
        if (loc) {
            context.loc = loc;
        }
        cb(context);
    },
    error(sessionId, context, error) {
        console.log(error.message);
    },
    ['forecast-all'](sessionId, context, cb) {
        // Here should go the api call, e.g.:
        `enter code here`
        context.forecast = getWeather(context.loc)
        cb(context);
    },

    ['forecast-feelslike'](sessionId, context, cb) {
        // Here should go the api call, e.g.:
        context.forecast = getFeelslike(context.loc)
        cb(context);
    },
};
4

1 回答 1

0

我不确定答案,但似乎您在未正确定义的变量上使用了字符串替换方法。

如果您可以显示您的代码,我可以更好地帮助您。

于 2016-06-14T18:42:39.413 回答