我正在尝试在Wit.ai中定义Node.js中的多个动作编码,我收到错误 -
" [error] [converse]错误: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);
},
};
答案 0 :(得分:0)
我不确定答案,但似乎你对未正确定义的变量使用了字符串替换方法。
如果您可以展示您的代码,我可以更好地帮助您。