Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let cb = (err, result) => {
if (err) return node.warn(err);
helper.setByString(data, config.output || 'payload', result)
node.send(data);
}
request(req, (err, response, body) => {
if (err) return node.error(err);
helper.setByString(data, output, JSON.parse(body));
return node.send(data);
});
}
rekognition[action](params = parameters, function (err, res) {
if (err) {
helper.setByString(data, config.output || "payload" , { error: err });
node.warn("AWS Lex: Error - postText - " + err);
return node.send(data);
}
helper.setByString(data, config.output || "payload" , res);
return node.send(data);
});
}
function cb(err, response) {
if (err) {
node.warn(err);
return node.send(data);
}
helper.setByString(data, output, response.json);
return node.send(data);
}
request(req, (err, response, body) => {
if (err) return node.error(err);
helper.setByString(data, output, (typeof body === "object") ? body : JSON.parse(body));
return node.send(data);
});
}
const getMessageContext = (message) => {
if (message === undefined) return;
let uuid = helper.getByString(message, _CONTEXT_KEY);
let context = _CONTEXTS.get(uuid);
if (!context) {
context = {};
let convId = helper.getByString(message, 'address.conversation.id');
uuid = convId + '-' + uuidv4();
helper.setByString(message, _CONTEXT_KEY, uuid);
_CONTEXTS.set(uuid, context);
}
return context;
}
const getMessageContext = (message) => {
if (message === undefined) return;
let uuid = helper.getByString(message, _CONTEXT_KEY);
let context = _CONTEXTS.get(uuid);
if (!context) {
context = {};
let convId = helper.getByString(message, 'address.conversation.id');
uuid = convId + '-' + uuidv4();
helper.setByString(message, _CONTEXT_KEY, uuid);
_CONTEXTS.set(uuid, context);
}
return context;
}
const getMessageContext = (message) => {
if (message === undefined) return;
let uuid = helper.getByString(message, _CONTEXT_KEY);
let context = _CONTEXTS.get(uuid);
if (!context) {
context = {};
let convId = helper.getByString(message, 'address.conversation.id');
uuid = convId + '-' + uuidv4();
helper.setByString(message, _CONTEXT_KEY, uuid);
_CONTEXTS.set(uuid, context);
}
return context;
}
const getMessageContext = message => {
if (message === undefined) return;
let uuid = helper.getByString(message, _CONTEXT_KEY);
let context = _CONTEXTS.get(uuid);
if (!context) {
context = {};
let convId = helper.getByString(message, "address.conversation.id");
uuid = convId + "-" + uuidv4();
helper.setByString(message, _CONTEXT_KEY, uuid);
_CONTEXTS.set(uuid, context);
}
return context;
};